Skip to content

Commit

Permalink
scripts: add ignore-not-found for undeploy and uninstall to Makefile …
Browse files Browse the repository at this point in the history
…boiler plate

This avoid failure of any of these two commands if for some
reason one or more of the kustomized resource is missing.

Part of 5195

Signed-off-by: Samuel Gaist <samuel.gaist@idiap.ch>
  • Loading branch information
sgaist committed Oct 12, 2024
1 parent 819984d commit 666ed4f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
The make uninstall and undeploy command from the generated Makefile
now properly handle missing kustomized resources.
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "bugfix"
# Is this a breaking change?
breaking: false
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
#
# The generator auto-detects the PR number from the commit
# message in which this file was originally added.
#
# What is the pull request number (without the "#")?
# pull_request_override: 0
# Migration can be defined to automatically add a section to
# the migration guide. This is required for breaking changes.
# migration:
# header: Header text for the migration section
# body: |
# Body of the migration section. This should be formatted as markdown and can
# span multiple lines.
#
# Using the YAML string '|' operator means that newlines in this string will
# be honored and interpretted as newlines in the rendered markdown.
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
##@ Deployment
ifndef ignore-not-found
ignore-not-found = false
endif
.PHONY: install
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -
.PHONY: uninstall
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
Expand All @@ -133,7 +137,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c
.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
Expand Down
8 changes: 6 additions & 2 deletions testdata/helm/memcached-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: install
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: uninstall
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
Expand All @@ -118,7 +122,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
Expand Down

0 comments on commit 666ed4f

Please sign in to comment.