Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: BPFMAN_IMG & BPFMAN_AGENT_IMG to overwrite image #18

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)@' \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u could use yq to replace in place the image as well and avoid the tmp kustomize ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we discussed yq in the past, but decided we didn't want to add another tool. We are already doing something similar in the examples Makefile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI sed require some magic to work on mac os, probably something like

ifeq (,$(shell which gsed 2>/dev/null))
SED ?= sed
else
SED ?= gsed
endif

then use SED everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I don't think anyone has tried to build/run on a MAC, but should probably be added to the list.

-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
Loading