diff --git a/.gitignore b/.gitignore index b4beb720c..ad1c9235b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ go.work # make generate folder /github.com + +# Temporary Kustomize file +config/bpfman-deployment/kustomization.yaml diff --git a/Makefile b/Makefile index 4ee221cf8..b8950a4f9 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/config/bpfman-deployment/kustomization.yaml b/config/bpfman-deployment/kustomization.yaml deleted file mode 100644 index 588074f99..000000000 --- a/config/bpfman-deployment/kustomization.yaml +++ /dev/null @@ -1,11 +0,0 @@ -resources: -- config.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: quay.io/bpfman/bpfman - newName: quay.io/bpfman/bpfman - newTag: latest -- name: quay.io/bpfman/bpfman-agent - newName: quay.io/bpfman/bpfman-agent - newTag: latest diff --git a/config/bpfman-deployment/kustomization.yaml.env b/config/bpfman-deployment/kustomization.yaml.env new file mode 100644 index 000000000..675494aea --- /dev/null +++ b/config/bpfman-deployment/kustomization.yaml.env @@ -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