@@ -36,6 +36,8 @@ export GO111MODULE=on
36
36
# This option is for running docker manifest command
37
37
export DOCKER_CLI_EXPERIMENTAL := enabled
38
38
39
+ CURL_RETRIES =3
40
+
39
41
# Directories
40
42
TOOLS_DIR := $(ROOT ) /hack/tools
41
43
TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
@@ -82,7 +84,11 @@ ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)-$(ENVSUBST_VER)
82
84
83
85
GO_APIDIFF_VER := v0.5.0
84
86
GO_APIDIFF_BIN := go-apidiff
85
- GO_APIDIFF := $(TOOLS_BIN_DIR ) /$(GO_APIDIFF_BIN )
87
+ GO_APIDIFF := $(TOOLS_BIN_DIR ) /$(GO_APIDIFF_BIN ) -$(GO_APIDIFF_VER )
88
+
89
+ HELM_VER := v3.8.1
90
+ HELM_BIN := helm
91
+ HELM := $(TOOLS_BIN_DIR ) /$(HELM_BIN ) -$(HELM_VER )
86
92
87
93
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
88
94
TAG ?= dev
@@ -115,8 +121,11 @@ SKIP_CREATE_MGMT_CLUSTER ?= false
115
121
116
122
# Relase
117
123
RELEASE_TAG := $(shell git describe --abbrev=0 2>/dev/null)
124
+ HELM_CHART_TAG := $(shell echo $(RELEASE_TAG ) | cut -c 2-)
118
125
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF )
119
126
RELEASE_DIR := out
127
+ CHART_DIR := $(RELEASE_DIR ) /charts/cluster-api-operator
128
+ CHART_PACKAGE_DIR := $(RELEASE_DIR ) /package
120
129
121
130
all : generate test operator
122
131
@@ -135,6 +144,7 @@ controller-gen: $(CONTROLLER_GEN) ## Build a local copy of controller-gen.
135
144
setup-envtest : $(SETUP_ENVTEST ) # # Build a local copy of setup-envtest.
136
145
golangci-lint : $(GOLANGCI_LINT ) # # Build a local copy of golang ci-lint.
137
146
gotestsum : $(GOTESTSUM ) # # Build a local copy of gotestsum.
147
+ helm : $(HELM ) # # Build a local copy of helm.
138
148
139
149
$(KUSTOMIZE ) : # # Build kustomize from tools folder.
140
150
GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN ) $(KUSTOMIZE_VER )
@@ -160,6 +170,15 @@ $(GOTESTSUM): # Build gotestsum from tools folder.
160
170
$(GOLANGCI_LINT ) : # # Build golangci-lint from tools folder.
161
171
GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN ) $(GOLANGCI_LINT_VER )
162
172
173
+ $(HELM ) : # # Put helm into tools folder.
174
+ mkdir -p $(TOOLS_BIN_DIR )
175
+ rm -f " $( TOOLS_BIN_DIR) /$( HELM_BIN) *"
176
+ curl --retry $(CURL_RETRIES ) -fsSL -o $(TOOLS_BIN_DIR ) /get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
177
+ chmod 700 $(TOOLS_BIN_DIR ) /get_helm.sh
178
+ USE_SUDO=false HELM_INSTALL_DIR=$(TOOLS_BIN_DIR ) DESIRED_VERSION=$(HELM_VER ) BINARY_NAME=$(HELM_BIN ) -$(HELM_VER ) $(TOOLS_BIN_DIR ) /get_helm.sh
179
+ ln -sf $(HELM ) $(TOOLS_BIN_DIR ) /$(HELM_BIN )
180
+ rm -f $(TOOLS_BIN_DIR ) /get_helm.sh
181
+
163
182
.PHONY : cert-mananger
164
183
cert-manager : # Install cert-manager on the cluster. This is used for development purposes only.
165
184
$(ROOT ) /hack/cert-manager.sh
@@ -330,14 +349,22 @@ set-manifest-image:
330
349
$(RELEASE_DIR ) :
331
350
mkdir -p $(RELEASE_DIR ) /
332
351
352
+ $(CHART_DIR ) :
353
+ mkdir -p $(CHART_DIR ) /templates
354
+
355
+ $(CHART_PACKAGE_DIR ) :
356
+ mkdir -p $(CHART_PACKAGE_DIR )
357
+
333
358
.PHONY : release
334
359
release : clean-release $(RELEASE_DIR ) # # Builds and push container images using the latest git tag for the commit.
335
360
@if [ -z " ${RELEASE_TAG} " ]; then echo " RELEASE_TAG is not set" ; exit 1; fi
336
361
@if ! [ -z " $$ (git status --porcelain)" ]; then echo " Your local git repository contains uncommitted changes, use git clean before proceeding." ; exit 1; fi
337
362
git checkout " ${RELEASE_TAG} "
338
363
# Set the manifest image to the production bucket.
339
364
$(MAKE ) manifest-modification REGISTRY=$(PROD_REGISTRY )
365
+ $(MAKE ) chart-manifest-modification REGISTRY=$(PROD_REGISTRY )
340
366
$(MAKE ) release-manifests
367
+ $(MAKE ) release-chart
341
368
342
369
.PHONY : manifest-modification
343
370
manifest-modification : # Set the manifest images to the staging/production bucket.
@@ -346,10 +373,22 @@ manifest-modification: # Set the manifest images to the staging/production bucke
346
373
TARGET_RESOURCE=" ./config/default/manager_image_patch.yaml"
347
374
$(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" ./config/default/manager_pull_policy.yaml"
348
375
376
+ .PHONY : chart-manifest-modification
377
+ chart-manifest-modification : # Set the manifest images to the staging/production bucket.
378
+ $(MAKE ) set-manifest-image \
379
+ MANIFEST_IMG=$(REGISTRY ) /$(IMAGE_NAME ) MANIFEST_TAG=$(RELEASE_TAG ) \
380
+ TARGET_RESOURCE=" ./config/chart/manager_image_patch.yaml"
381
+ $(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" ./config/chart/manager_pull_policy.yaml"
382
+
349
383
.PHONY : release-manifests
350
384
release-manifests : $(KUSTOMIZE ) $(RELEASE_DIR ) # # Builds the manifests to publish with a release
351
385
$(KUSTOMIZE ) build ./config/default > $(RELEASE_DIR ) /operator-components.yaml
352
386
387
+ release-chart : $(HELM ) $(KUSTOMIZE ) $(RELEASE_DIR ) $(CHART_DIR ) $(CHART_PACKAGE_DIR ) # # Builds the chart to publish with a release
388
+ $(KUSTOMIZE ) build ./config/chart > $(CHART_DIR ) /templates/operator-components.yaml
389
+ cp -rf $(ROOT ) /hack/chart/. $(CHART_DIR )
390
+ $(HELM ) package $(CHART_DIR ) --app-version=$(HELM_CHART_TAG ) --version=$(HELM_CHART_TAG ) --destination=$(CHART_PACKAGE_DIR )
391
+
353
392
.PHONY : release-staging
354
393
release-staging : # # Builds and push container images and manifests to the staging bucket.
355
394
$(MAKE ) docker-build-all
@@ -366,6 +405,10 @@ release-alias-tag: # Adds the tag to the last build tag.
366
405
upload-staging-artifacts : # # Upload release artifacts to the staging bucket
367
406
gsutil cp $(RELEASE_DIR ) /* gs://$(STAGING_BUCKET ) /components/$(RELEASE_ALIAS_TAG ) /
368
407
408
+ .PHONY : update-helm-repo
409
+ update-helm-repo :
410
+ ./hack/update-helm-repo.sh $(RELEASE_TAG )
411
+
369
412
# # --------------------------------------
370
413
# # Cleanup / Verification
371
414
# # --------------------------------------
0 commit comments