Skip to content

Commit 3e25ad0

Browse files
committed
Add overlay for deployment
1 parent b558106 commit 3e25ad0

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{/*
2+
This template gets filled with the operator SDK's controller definition
3+
during chart build
4+
*/}}
5+
{{- define "awx-operator.controller" -}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- $controllerTemplate := (include "awx-operator.controller" $) | fromYaml }}
2+
3+
{{- $existingLabels := default dict ($controllerTemplate.metadata).labels }}
4+
{{- $mergedLabels := mergeOverwrite $existingLabels $.Values.controller.labels }}
5+
{{- /* Use set in case the dict didn't exist */}}
6+
{{- $_ := set $controllerTemplate.metadata "labels" $mergedLabels }}
7+
8+
{{- $existingAnnotations := default dict ($controllerTemplate.metadata).annotations }}
9+
{{- $mergedAnnotations := mergeOverwrite $existingAnnotations $.Values.controller.annotations }}
10+
{{- /* Use set in case the dict didn't exist */}}
11+
{{- $_ := set $controllerTemplate.metadata "annotations" $mergedAnnotations }}
12+
13+
{{- $_ := mergeOverwrite $controllerTemplate.spec $.Values.controller.spec }}
14+
15+
{{ $controllerTemplate | toYaml }}

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,24 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
148148
for file in charts/$(CHART_NAME)/raw-files/*rolebinding*; do\
149149
$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $${file};\
150150
done
151-
# Add .spec.replicas for the controller-manager deployment
152-
for file in charts/$(CHART_NAME)/raw-files/deployment-*-controller-manager.yaml; do\
153-
$(YQ) -i '.spec.replicas = "{{ (.Values.Operator).replicas | default 1 }}"' $${file};\
154-
done
151+
155152
# Correct .metadata.name for cluster scoped resources
156153
cluster_scoped_files="charts/$(CHART_NAME)/raw-files/clusterrolebinding-awx-operator-proxy-rolebinding.yaml charts/$(CHART_NAME)/raw-files/clusterrole-awx-operator-metrics-reader.yaml charts/$(CHART_NAME)/raw-files/clusterrole-awx-operator-proxy-role.yaml";\
157154
for file in $${cluster_scoped_files}; do\
158155
$(YQ) -i '.metadata.name += "-{{ .Release.Name }}"' $${file};\
159156
done
160157
# Correct the reference for the clusterrolebinding
161158
$(YQ) -i '.roleRef.name += "-{{ .Release.Name }}"' 'charts/$(CHART_NAME)/raw-files/clusterrolebinding-awx-operator-proxy-rolebinding.yaml'
162-
# Correct .spec.replicas type for the controller-manager deployment
159+
160+
# Feed controller deployment file into template to allow for override from values
163161
for file in charts/$(CHART_NAME)/raw-files/deployment-*-controller-manager.yaml; do\
164-
$(SED_I) "s/'{{ (.Values.Operator).replicas | default 1 }}'/{{ (.Values.Operator).replicas | default 1 }}/g" $${file};\
162+
cat $${file} >> charts/$(CHART_NAME)/templates/controller/_controller.tpl;\
163+
echo "\n---" >> charts/$(CHART_NAME)/templates/controller/_controller.tpl;\
164+
rm -f $${file} ;\
165165
done
166+
echo '{{- end -}}' >> charts/$(CHART_NAME)/templates/controller/_controller.tpl
167+
168+
166169
# move all custom resource definitions to crds folder
167170
mkdir charts/$(CHART_NAME)/crds
168171
mv charts/$(CHART_NAME)/raw-files/customresourcedefinition*.yaml charts/$(CHART_NAME)/crds/.

0 commit comments

Comments
 (0)