From 7dce1cc6674f6ed4ab4faff719c29e724383b4e9 Mon Sep 17 00:00:00 2001 From: Michael Nairn Date: Wed, 15 Nov 2023 11:21:32 +0000 Subject: [PATCH] Fix gateway controller deploy target `make deploy-gateway-controller` deploys both the gateway and policy controller but was only updating the image for the gateway controller to the locally built version. This chnage updates the make targets to ensure that both the gateway and policy controller images are updated when testing the combined gateway/policy controller installation (e2e tests). --- .gitignore | 2 ++ config/deploy/local/kustomization.yaml | 22 ++++--------------- config/deploy/local/manager_config_patch.yaml | 2 +- config/manager/kustomization.yaml | 2 +- .../deploy/local/kustomization.yaml | 10 +++++++++ .../deploy/local/manager_config_patch.yaml | 11 ++++++++++ .../manager/kustomization.yaml | 4 +--- hack/make/gateway_controller.make | 7 ++++-- hack/make/policy_controller.make | 9 +++++--- 9 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 config/policy-controller/deploy/local/kustomization.yaml create mode 100644 config/policy-controller/deploy/local/manager_config_patch.yaml diff --git a/.gitignore b/.gitignore index 389a5409d..2a25e5461 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ vendor/ #Ignore local directory (for stuff to keep locally) local/ +!config/deploy/local +!config/policy-controller/deploy/local #Ignore .kcp directory .kcp/ diff --git a/config/deploy/local/kustomization.yaml b/config/deploy/local/kustomization.yaml index 97e72d394..8fca252a6 100644 --- a/config/deploy/local/kustomization.yaml +++ b/config/deploy/local/kustomization.yaml @@ -1,25 +1,11 @@ # Local deployment overlay. # -# This requires the following .env files to exist in the project directory before -# it can be used: -# controller-config.env -# aws-credentials.env +# Set the deployment imagePullPolicy to Never. This is required if you are using a local image loaded into kind i.e. make kind-load-gateway-controller +# resources: - ../../default -generatorOptions: - disableNameSuffixHash: true - -configMapGenerator: - - name: controller-config - envs: - - ../../../controller-config.env - -secretGenerator: - - name: aws-credentials - envs: - - ../../../aws-credentials.env - patchesStrategicMerge: -- manager_config_patch.yaml \ No newline at end of file +- manager_config_patch.yaml +- ../../policy-controller/deploy/local/manager_config_patch.yaml diff --git a/config/deploy/local/manager_config_patch.yaml b/config/deploy/local/manager_config_patch.yaml index ccb91b8e8..91eb7d606 100644 --- a/config/deploy/local/manager_config_patch.yaml +++ b/config/deploy/local/manager_config_patch.yaml @@ -8,4 +8,4 @@ spec: spec: containers: - name: manager - imagePullPolicy: Never \ No newline at end of file + imagePullPolicy: Never diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index d14ea4725..cf5e1b32e 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,4 +4,4 @@ resources: images: - name: controller newName: quay.io/kuadrant/multicluster-gateway-controller - newTag: main \ No newline at end of file + newTag: main diff --git a/config/policy-controller/deploy/local/kustomization.yaml b/config/policy-controller/deploy/local/kustomization.yaml new file mode 100644 index 000000000..c4b91bde7 --- /dev/null +++ b/config/policy-controller/deploy/local/kustomization.yaml @@ -0,0 +1,10 @@ +# Local deployment overlay. +# +# Set the deployment imagePullPolicy to Never. This is required if you are using a local image loaded into kind i.e. make kind-load-policy-controller +# + +resources: + - ../../default + +patchesStrategicMerge: +- manager_config_patch.yaml diff --git a/config/policy-controller/deploy/local/manager_config_patch.yaml b/config/policy-controller/deploy/local/manager_config_patch.yaml new file mode 100644 index 000000000..14c206124 --- /dev/null +++ b/config/policy-controller/deploy/local/manager_config_patch.yaml @@ -0,0 +1,11 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: policy-controller + namespace: system +spec: + template: + spec: + containers: + - name: policy-controller + imagePullPolicy: Never diff --git a/config/policy-controller/manager/kustomization.yaml b/config/policy-controller/manager/kustomization.yaml index 441a2bc8b..344937267 100644 --- a/config/policy-controller/manager/kustomization.yaml +++ b/config/policy-controller/manager/kustomization.yaml @@ -1,9 +1,7 @@ - - resources: - manager.yaml images: - name: policy-controller newName: quay.io/kuadrant/policy-controller - newTag: main \ No newline at end of file + newTag: main diff --git a/hack/make/gateway_controller.make b/hack/make/gateway_controller.make index 8b78bcaf4..1d4401de9 100644 --- a/hack/make/gateway_controller.make +++ b/hack/make/gateway_controller.make @@ -27,9 +27,12 @@ kind-load-gateway-controller: docker-build-gateway-controller docker-push-gateway-controller: ## Push docker image with the controller. docker push ${CONTROLLER_IMG} -.PHONY: deploy-gateway-controller -deploy-gateway-controller: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. +.PHONY: update-gateway-controller-image +update-gateway-controller-image: kustomize ## Update gateway controller image to CONTROLLER_IMG. cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG} + +.PHONY: deploy-gateway-controller +deploy-gateway-controller: manifests kustomize update-gateway-controller-image update-policy-controller-image ## Deploy controller to the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) --load-restrictor LoadRestrictionsNone build config/deploy/local | kubectl apply -f - @if [ "$(METRICS)" = "true" ]; then\ $(KUSTOMIZE) build config/prometheus | kubectl apply -f -;\ diff --git a/hack/make/policy_controller.make b/hack/make/policy_controller.make index b97c2e048..86d3bc6db 100644 --- a/hack/make/policy_controller.make +++ b/hack/make/policy_controller.make @@ -39,10 +39,13 @@ kind-load-policy-controller: docker-build-policy-controller docker-push-policy-controller: ## Push docker image with the controller. docker push ${POLICY_CONTROLLER_IMG} +.PHONY: update-policy-controller-image +update-policy-controller-image: kustomize ## Update policy controller image to POLICY_CONTROLLER_IMG. + cd config/policy-controller/manager && $(KUSTOMIZE) edit set image policy-controller=${POLICY_CONTROLLER_IMG} + .PHONY: deploy-policy-controller -deploy-policy-controller: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/policy-controller/default && $(KUSTOMIZE) edit set image policy-controller=${POLICY_CONTROLLER_IMG} - $(KUSTOMIZE) --load-restrictor LoadRestrictionsNone build config/policy-controller/default | kubectl apply -f - +deploy-policy-controller: kustomize manifests update-policy-controller-image ## Deploy policy controller to the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) --load-restrictor LoadRestrictionsNone build config/policy-controller/deploy/local | kubectl apply -f - @if [ "$(METRICS)" = "true" ]; then\ $(KUSTOMIZE) build config/prometheus | kubectl apply -f -;\ fi