Skip to content

Commit

Permalink
Merge pull request #18 from Billy99/billy99-kustomize-image
Browse files Browse the repository at this point in the history
build: BPFMAN_IMG & BPFMAN_AGENT_IMG to overwrite image
  • Loading branch information
Billy99 committed Jun 5, 2024
2 parents 96ce268 + aa19fa7 commit ee50b19
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ go.work

# make generate folder
/github.com

# Temporary Kustomize file
config/bpfman-deployment/kustomization.yaml
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ test: fmt envtest ## Run Unit tests.
.PHONY: test-integration
test-integration: ## Run Integration tests.
go clean -testcache
cd config/bpfman-deployment && \
sed -e 's@bpfman\.image=.*@bpfman.image=$(BPFMAN_IMG)@' \
-e 's@bpfman\.agent\.image=.*@bpfman.agent.image=$(BPFMAN_AGENT_IMG)@' \
kustomization.yaml.env > kustomization.yaml
GOFLAGS="-tags=integration_tests" go test -race -v ./test/integration/...

## The physical bundle is no longer tracked in git since it should be considered
Expand All @@ -300,8 +304,10 @@ test-integration: ## Run Integration tests.
.PHONY: bundle
bundle: operator-sdk generate kustomize manifests ## Generate bundle manifests and metadata, then validate generated files.
cd config/bpfman-operator-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-operator=${BPFMAN_OPERATOR_IMG}
cd config/bpfman-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman=${BPFMAN_IMG} &&\
$(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-agent=${BPFMAN_AGENT_IMG}
cd config/bpfman-deployment && \
sed -e 's@bpfman\.image=.*@bpfman.image=$(BPFMAN_IMG)@' \
-e 's@bpfman\.agent\.image=.*@bpfman.agent.image=$(BPFMAN_AGENT_IMG)@' \
kustomization.yaml.env > kustomization.yaml
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
cp config/manifests/dependencies.yaml bundle/metadata/
$(OPERATOR_SDK) bundle validate ./bundle
Expand Down Expand Up @@ -456,8 +462,10 @@ destroy-kind: ## Destroy Kind cluster
.PHONY: deploy
deploy: manifests kustomize ## Deploy bpfman-operator to the K8s cluster specified in ~/.kube/config with the csi driver initialized.
cd config/bpfman-operator-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-operator=${BPFMAN_OPERATOR_IMG}
cd config/bpfman-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman=${BPFMAN_IMG} && \
$(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-agent=${BPFMAN_AGENT_IMG}
cd config/bpfman-deployment && \
sed -e 's@bpfman\.image=.*@bpfman.image=$(BPFMAN_IMG)@' \
-e 's@bpfman\.agent\.image=.*@bpfman.agent.image=$(BPFMAN_AGENT_IMG)@' \
kustomization.yaml.env > kustomization.yaml
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
Expand All @@ -479,8 +487,10 @@ run-on-kind: kustomize setup-kind build-images load-images-kind deploy ## Kind D
.PHONY: deploy-openshift
deploy-openshift: manifests kustomize ## Deploy bpfman-operator to the Openshift cluster specified in ~/.kube/config.
cd config/bpfman-operator-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-operator=${BPFMAN_OPERATOR_IMG}
cd config/bpfman-deployment && $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman=${BPFMAN_IMG} \
&& $(KUSTOMIZE) edit set image quay.io/bpfman/bpfman-agent=${BPFMAN_AGENT_IMG}
cd config/bpfman-deployment && \
sed -e 's@bpfman\.image=.*@bpfman.image=$(BPFMAN_IMG)@' \
-e 's@bpfman\.agent\.image=.*@bpfman.agent.image=$(BPFMAN_AGENT_IMG)@' \
kustomization.yaml.env > kustomization.yaml
$(KUSTOMIZE) build config/openshift | kubectl apply -f -

.PHONY: undeploy-openshift
Expand Down
11 changes: 0 additions & 11 deletions config/bpfman-deployment/kustomization.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions config/bpfman-deployment/kustomization.yaml.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resources:
- config.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Patch the config.yaml to change bpfman and bpfman-agent image and tag.
# Because it is of "kind: ConfigMap", the data is opaque and kustomize can't
# update image magically.
configMapGenerator:
- behavior: merge
literals:
- bpfman.image=quay.io/bpfman/bpfman:latest
- bpfman.agent.image=quay.io/bpfman/bpfman-agent:latest
name: config
namespace: kube-system

0 comments on commit ee50b19

Please sign in to comment.