Skip to content

Commit 73c297c

Browse files
committed
build(makefile): update Makefile for Helm chart deployment
- Set default image registry to registry-cn-beijing.ack.aliyuncs.com - Update image repository to acs/cron-operator - Derive image tag from VERSION file by stripping leading 'v' - Construct full image URL using registry, repository, and tag variables - Add Helm chart directory, release name, and namespace variables - Add helm-upgrade target to install or upgrade Helm chart with image settings - Add helm-uninstall target to remove Helm chart release - Add print-% target for easier variable inspection during development Signed-off-by: Yi Chen <github@chenyicn.net>
1 parent beb9c75 commit 73c297c

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

Makefile

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@ else
55
GOBIN=$(shell go env GOBIN)
66
endif
77

8+
# Version of cron-operator (e.g. `v1.2.3`).
9+
VERSION ?= $(shell cat VERSION)
10+
811
# Image registry (e.g. `docker.io`)
9-
IMAGE_REGISTRY ?= docker.io
12+
IMAGE_REGISTRY ?= registry-cn-beijing.ack.aliyuncs.com
1013
# Image repository (e.g. `my-repo/my-image`).
11-
IMAGE_REPOSITORY ?= cron-operator
12-
# Image tag (e.g. `latest`).
13-
IMAGE_TAG ?= latest
14+
IMAGE_REPOSITORY ?= acs/cron-operator
15+
# Image tag (e.g. `latest` or `1.2.3`).
16+
IMAGE_TAG ?= $(shell sed 's/^v//g' VERSION)
1417
# Image URL to use all building/pushing image targets
15-
IMAGE ?= $(IMAGE_REPOSITORY):$(IMAGE_TAG)
18+
IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY):$(IMAGE_TAG)
19+
20+
# Cron operator chart directory.
21+
CRON_OPERATOR_CHART ?= charts/cron-operator
22+
# Helm release name.
23+
RELEASE_NAME ?= cron-operator
24+
# Helm release namespace.
25+
RELEASE_NAMESPACE ?= cron-operator
1626

1727
# CONTAINER_TOOL defines the container tool to be used for building images.
1828
# Be aware that the target commands are only tested with Docker which is
@@ -45,6 +55,9 @@ all: build
4555
help: ## Display this help.
4656
@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)
4757

58+
.PHONY: print-%
59+
print-%: ; @echo $*=$($*)
60+
4861
##@ Development
4962

5063
.PHONY: manifests
@@ -162,6 +175,21 @@ helm-unittest: helm-unittest-plugin ## Run Helm chart unittests.
162175
helm-docs: helm-docs-plugin ## Generates markdown documentation for helm charts from requirements and values files.
163176
$(HELM_DOCS) --sort-values-order=file
164177

178+
.PHONY: helm-upgrade
179+
helm-upgrade: ## Upgrade cron-operator helm chart release (install if not exists).
180+
$(HELM) upgrade $(RELEASE_NAME) $(CRON_OPERATOR_CHART) \
181+
--install \
182+
--namespace $(RELEASE_NAMESPACE) \
183+
--create-namespace \
184+
--wait \
185+
--set image.registry=${IMAGE_REGISTRY} \
186+
--set image.repository=${IMAGE_REPOSITORY} \
187+
--set image.tag=${IMAGE_TAG}
188+
189+
.PHONY: helm-uninstall
190+
helm-uninstall: ## Uninstall cron-operator helm chart release.
191+
$(HELM) uninstall $(RELEASE_NAME) --namespace $(RELEASE_NAMESPACE)
192+
165193
##@ Deployment
166194

167195
ifndef ignore-not-found

0 commit comments

Comments
 (0)