From 3cd9ddd8c625d8e8294f5603f40d28a7183fd23b Mon Sep 17 00:00:00 2001 From: Brandon Ewing Date: Sat, 18 Jun 2022 23:02:54 -0500 Subject: [PATCH] remove namespace from helm chart Helm should be able to set the namespace for the operator at deploy time via the --namespace option. Use yq to remove all references to namespaces in the helm chart prior to publishing. Update CI process to create namespace during install. Resolves #907 --- .github/workflows/ci.yaml | 2 +- Makefile | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b1518456..dbcf76756 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -63,4 +63,4 @@ jobs: - name: Build and install helm chart run: | IMG=awx-operator-ci make helm-chart - helm install --wait my-awx-operator ./charts/awx-operator + helm install --wait my-awx-operator --namespace awx --create-namespace ./charts/awx-operator diff --git a/Makefile b/Makefile index 7cfdf95bd..fd550de23 100644 --- a/Makefile +++ b/Makefile @@ -272,7 +272,6 @@ charts: helm-chart: kustomize helm kubectl-slice yq charts @echo "== KUSTOMIZE (image and namespace) ==" cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE} @echo "== HELM ==" cd charts && \ @@ -293,6 +292,9 @@ helm-chart: kustomize helm kubectl-slice yq charts --output-dir=charts/$(CHART_NAME)/templates \ --sort-by-kind @echo "Helm Chart $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt + $(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*),$(YQ) -i 'del(.. | select(has("namespace")).namespace)' $(file);) + $(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*rolebinding*),$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $(file);) + rm -f charts/$(CHART_NAME)/templates/namespace*.yaml .PHONY: helm-package