|
| 1 | +# |
| 2 | +#Copyright 2025 NVIDIA |
| 3 | +# |
| 4 | +#Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +#you may not use this file except in compliance with the License. |
| 6 | +#You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +#Unless required by applicable law or agreed to in writing, software |
| 11 | +#distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +#See the License for the specific language governing permissions and |
| 14 | +#limitations under the License. |
| 15 | + |
| 16 | +# Get the directory of this Makefile, regardless of where make was invoked |
| 17 | +PROJECT_DIR := $(shell cd $(dir $(lastword $(MAKEFILE_LIST))) && pwd -L) |
| 18 | +PROJECT_DIR := $(patsubst %/,%,$(PROJECT_DIR)) |
| 19 | + |
| 20 | +# Export is needed here so that the envsubst used in make targets has access to those variables even when they are not |
| 21 | +# explicitly set when calling make. |
| 22 | +export TAG ?= v0.0.1 |
| 23 | +export REGISTRY ?= example.com |
| 24 | + |
| 25 | + |
| 26 | +# By default the helm registry is assumed to be an OCI registry. |
| 27 | +export HELM_REGISTRY ?= oci://$(REGISTRY) |
| 28 | + |
| 29 | +# Chart configuration |
| 30 | +CHARTS_DIR = $(PROJECT_DIR)/charts |
| 31 | +CHARTS_OUTPUT_DIR = $(PROJECT_DIR)/output |
| 32 | + |
| 33 | +# Detect architecture and platform |
| 34 | +TOOL_ARCH ?= $(shell uname -m) |
| 35 | +TOOL_OS ?= $(shell uname -s | tr A-Z a-z) |
| 36 | + |
| 37 | +HELM_ARCH = $(TOOL_ARCH) |
| 38 | +ifeq ($(TOOL_ARCH),x86_64) |
| 39 | + HELM_ARCH = amd64 |
| 40 | +else ifeq ($(TOOL_ARCH),aarch64) |
| 41 | + HELM_ARCH = arm64 |
| 42 | +endif |
| 43 | + |
| 44 | +# Tool versions |
| 45 | +HELM_VER ?= v3.18.3 |
| 46 | +HELM_CM_PUSH_VERSION ?= 0.10.4 |
| 47 | + |
| 48 | +# Tool binaries |
| 49 | +TOOLSDIR = $(PROJECT_DIR)/bin |
| 50 | +HELM ?= $(TOOLSDIR)/helm-$(HELM_VER) |
| 51 | + |
| 52 | +# Setting SHELL to bash allows bash commands to be executed by recipes. |
| 53 | +SHELL = /usr/bin/env bash -o pipefail |
| 54 | +.SHELLFLAGS = -ec |
| 55 | + |
| 56 | +##@ General |
| 57 | + |
| 58 | +.PHONY: help |
| 59 | +help: ## Display this help. |
| 60 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 61 | + |
| 62 | +$(TOOLSDIR) $(CHARTS_OUTPUT_DIR): |
| 63 | + @mkdir -p $@ |
| 64 | + |
| 65 | +##@ Tools |
| 66 | + |
| 67 | +.PHONY: helm |
| 68 | +helm: $(HELM) ## Download helm locally if necessary. |
| 69 | +$(HELM): | $(TOOLSDIR) |
| 70 | + @echo "Installing helm-$(HELM_VER) to $(TOOLSDIR)" |
| 71 | + @curl -fsSL https://get.helm.sh/helm-$(HELM_VER)-$(TOOL_OS)-$(HELM_ARCH).tar.gz | tar -xzf - --no-same-owner -C $(TOOLSDIR) --strip-components=1 |
| 72 | + @mv $(TOOLSDIR)/helm $(HELM) |
| 73 | + @chmod +x $(HELM) |
| 74 | + |
| 75 | +.PHONY: helm-cm-push |
| 76 | +helm-cm-push: helm |
| 77 | + @$(HELM) plugin list | grep cm-push | grep $(HELM_CM_PUSH_VERSION) || \ |
| 78 | + ( \ |
| 79 | + ($(HELM) plugin uninstall cm-push || true) && \ |
| 80 | + $(HELM) plugin install https://github.com/chartmuseum/helm-push --version $(HELM_CM_PUSH_VERSION) \ |
| 81 | + ) |
| 82 | + |
| 83 | +##@ Helm |
| 84 | + |
| 85 | +HELM_PUSH_CMD ?= $(shell if echo $(HELM_REGISTRY) | grep -q '^http'; then echo cm-push; else echo push; fi) |
| 86 | + |
| 87 | +# Individual chart targets |
| 88 | + |
| 89 | +# spdk-csi-controller chart |
| 90 | +.PHONY: helm-package-spdk-csi-controller |
| 91 | +helm-package-spdk-csi-controller: $(CHARTS_OUTPUT_DIR) helm ## Package spdk-csi-controller chart |
| 92 | + $(HELM) package $(CHARTS_DIR)/spdk-csi-controller --destination $(CHARTS_OUTPUT_DIR) --version $(TAG) |
| 93 | + |
| 94 | +.PHONY: helm-push-spdk-csi-controller |
| 95 | +helm-push-spdk-csi-controller: helm-package-spdk-csi-controller helm-cm-push ## Package and push spdk-csi-controller chart |
| 96 | + $(HELM) $(HELM_PUSH_CMD) $(CHARTS_OUTPUT_DIR)/spdk-csi-controller-$(TAG).tgz $(HELM_REGISTRY) |
| 97 | + |
| 98 | +.PHONY: lint-spdk-csi-controller |
| 99 | +lint-spdk-csi-controller: helm ## Run helm lint on spdk-csi-controller chart |
| 100 | + $(HELM) lint $(CHARTS_DIR)/spdk-csi-controller |
| 101 | + |
| 102 | +.PHONY: template-spdk-csi-controller |
| 103 | +template-spdk-csi-controller: helm ## Run helm template on spdk-csi-controller chart |
| 104 | + $(HELM) template --set dpu.enabled=true $(CHARTS_DIR)/spdk-csi-controller |
| 105 | + $(HELM) template --set host.enabled=true --set host.config.dpuClusterSecret=test-secret $(CHARTS_DIR)/spdk-csi-controller |
| 106 | + |
| 107 | +# nfs-csi-controller chart |
| 108 | +.PHONY: helm-package-nfs-csi-controller |
| 109 | +helm-package-nfs-csi-controller: $(CHARTS_OUTPUT_DIR) helm ## Package nfs-csi-controller chart |
| 110 | + $(HELM) package $(CHARTS_DIR)/nfs-csi-controller --destination $(CHARTS_OUTPUT_DIR) --version $(TAG) |
| 111 | + |
| 112 | +.PHONY: helm-push-nfs-csi-controller |
| 113 | +helm-push-nfs-csi-controller: helm-package-nfs-csi-controller helm-cm-push ## Package and push nfs-csi-controller chart |
| 114 | + $(HELM) $(HELM_PUSH_CMD) $(CHARTS_OUTPUT_DIR)/nfs-csi-controller-$(TAG).tgz $(HELM_REGISTRY) |
| 115 | + |
| 116 | +.PHONY: lint-nfs-csi-controller |
| 117 | +lint-nfs-csi-controller: helm ## Run helm lint on nfs-csi-controller chart |
| 118 | + $(HELM) lint $(CHARTS_DIR)/nfs-csi-controller |
| 119 | + |
| 120 | +.PHONY: template-nfs-csi-controller |
| 121 | +template-nfs-csi-controller: helm ## Run helm template on nfs-csi-controller chart |
| 122 | + $(HELM) template --set dpu.enabled=true $(CHARTS_DIR)/nfs-csi-controller |
| 123 | + $(HELM) template --set host.enabled=true --set host.config.dpuClusterSecret=test-secret $(CHARTS_DIR)/nfs-csi-controller |
| 124 | + |
| 125 | + |
| 126 | +.PHONY: helm-package |
| 127 | +helm-package: helm-package-spdk-csi-controller helm-package-nfs-csi-controller ## Package all helm charts |
| 128 | + |
| 129 | +.PHONY: helm-push |
| 130 | +helm-push: helm-push-spdk-csi-controller helm-push-nfs-csi-controller ## Push all helm charts |
| 131 | + |
| 132 | +.PHONY: lint |
| 133 | +lint: lint-spdk-csi-controller lint-nfs-csi-controller ## Run helm lint to validate all charts |
| 134 | + |
| 135 | +.PHONY: template |
| 136 | +template: template-spdk-csi-controller template-nfs-csi-controller ## Run helm template to generate all charts |
| 137 | + |
| 138 | +.PHONY: clean |
| 139 | +clean: ## Clean generated files |
| 140 | + @rm -rf $(CHARTS_OUTPUT_DIR) |
| 141 | + @rm -rf $(TOOLSDIR) |
0 commit comments