Skip to content

Commit f384220

Browse files
committed
Add Image Build And Helm Deployment To Makefile
To simplify building and deploying images for the operator locally I decided to add some targets to the Makefile Signed-off-by: Yannik Fuhrmeister <yannik.fuhrmeister@iteratec.com>
1 parent aa35eb8 commit f384220

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

‎operator/Makefile‎

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
# Image URL to use all building/pushing image targets
6-
IMG ?= securecodebox/operator:latest
5+
IMG_NS ?= securecodebox
6+
7+
# Image URL to use all building/pushing image targets for the operator
8+
OPERATOR_IMG ?= operator
9+
10+
# Image URL to use all building/pushing image targets for the lurker
11+
LURKER_IMG ?= lurker
12+
13+
# Tag used for the images
14+
IMG_TAG ?= sha-$$(git rev-parse --short HEAD)
15+
716
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
817
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
918

@@ -67,21 +76,48 @@ run: manifests generate fmt vet ## Run a controller from your host.
6776
go run ./main.go
6877

6978
docker-build: test ## Build docker image with the manager.
70-
docker build -t ${IMG} .
79+
@echo ".: ⚙️ Build Container Images"
80+
docker build -t $(IMG_NS)/${OPERATOR_IMG}:${IMG_TAG} .
81+
cd ../lurker && docker build -t $(IMG_NS)/$(LURKER_IMG):$(IMG_TAG) .
7182

7283
docker-push: ## Push docker image with the manager.
73-
docker push ${IMG}
84+
docker push $(IMG_NS)/${OPERATOR_IMG}:${IMG_TAG}
85+
docker push $(IMG_NS)/$(LURKER_IMG):$(IMG_TAG)
86+
87+
docker-export:
88+
@echo ".: 💾 Export Container Images"
89+
docker save $(IMG_NS)/$(OPERATOR_IMG):$(IMG_TAG) > $(OPERATOR_IMG).tar
90+
docker save $(IMG_NS)/$(LURKER_IMG):$(IMG_TAG) > $(LURKER_IMG).tar
7491

7592
##@ Deployment
7693

94+
kind-import:
95+
@echo ".: 💾 Importing the image archive to local kind cluster."
96+
kind load image-archive ./$(OPERATOR_IMG).tar
97+
kind load image-archive ./$(LURKER_IMG).tar
98+
99+
helm-deploy:
100+
@echo ".: ⚙️ Deploying Operator with the Image tag '$(IMG_TAG)' into kind."
101+
# If not exists create namespace where the tests will be executed
102+
kubectl create namespace integration-tests --dry-run=client -o yaml | kubectl apply -f -
103+
# If not exists create secureCodeBox operator namespace
104+
kubectl create namespace securecodebox-system --dry-run=client -o yaml | kubectl apply -f -
105+
helm -n securecodebox-system upgrade --install securecodebox-operator ./ --wait \
106+
--set="image.repository=docker.io/$(IMG_NS)/$(OPERATOR_IMG)" \
107+
--set="image.tag=$(IMG_TAG)" \
108+
--set="image.pullPolicy=IfNotPresent" \
109+
--set="lurker.image.repository=docker.io/$(IMG_NS)/$(LURKER_IMG)" \
110+
--set="lurker.image.tag=$(IMG_TAG)" \
111+
--set="lurker.pullPolicy=IfNotPresent"
112+
77113
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
78114
$(KUSTOMIZE) build config/crd | kubectl apply -f -
79115

80116
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
81117
$(KUSTOMIZE) build config/crd | kubectl delete -f -
82118

83119
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
84-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
120+
cd config/manager && $(KUSTOMIZE) edit set image controller=${OPERATOR_IMG}
85121
$(KUSTOMIZE) build config/default | kubectl apply -f -
86122

87123
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.

0 commit comments

Comments
 (0)