Skip to content

Commit f6ae5cd

Browse files
committed
Add overlay for deployment
1 parent d30ceff commit f6ae5cd

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed
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" -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- $operatorControllerTemplate := (include "awx-operator.controller" $) | fromYaml }}
2+
{{- $_ := mergeOverwrite $operatorControllerTemplate (index $.Values "operator-controller") }}
3+
4+
{{ $operatorControllerTemplate | toYaml }}

.helm/starter/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ AWX:
1717
password: Unset
1818
sslmode: prefer
1919
type: unmanaged
20+
21+
controller: {}

Makefile

+9-6
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,24 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
151151
for file in charts/$(CHART_NAME)/raw-files/*rolebinding*; do\
152152
$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $${file};\
153153
done
154-
# Add .spec.replicas for the controller-manager deployment
155-
for file in charts/$(CHART_NAME)/raw-files/deployment-*-controller-manager.yaml; do\
156-
$(YQ) -i '.spec.replicas = "{{ (.Values.Operator).replicas | default 1 }}"' $${file};\
157-
done
154+
158155
# Correct .metadata.name for cluster scoped resources
159156
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";\
160157
for file in $${cluster_scoped_files}; do\
161158
$(YQ) -i '.metadata.name += "-{{ .Release.Name }}"' $${file};\
162159
done
163160
# Correct the reference for the clusterrolebinding
164161
$(YQ) -i '.roleRef.name += "-{{ .Release.Name }}"' 'charts/$(CHART_NAME)/raw-files/clusterrolebinding-awx-operator-proxy-rolebinding.yaml'
165-
# Correct .spec.replicas type for the controller-manager deployment
162+
163+
# Feed controller deployment file into template to allow for override from values
166164
for file in charts/$(CHART_NAME)/raw-files/deployment-*-controller-manager.yaml; do\
167-
$(SED_I) "s/'{{ (.Values.Operator).replicas | default 1 }}'/{{ (.Values.Operator).replicas | default 1 }}/g" $${file};\
165+
cat $${file} >> charts/$(CHART_NAME)/templates/operator-controller/_operator-controller.tpl;\
166+
echo "\n---" >> charts/$(CHART_NAME)/templates/operator-controller/_operator-controller.tpl;\
167+
rm -f $${file} ;\
168168
done
169+
echo '{{- end -}}' >> charts/$(CHART_NAME)/templates/operator-controller/_operator-controller.tpl
170+
171+
169172
# move all custom resource definitions to crds folder
170173
mkdir charts/$(CHART_NAME)/crds
171174
mv charts/$(CHART_NAME)/raw-files/customresourcedefinition*.yaml charts/$(CHART_NAME)/crds/.

README.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Use `--force-conflicts` flag to resolve the conflict.
7878
kubectl apply --server-side --force-conflicts -k github.com/ansible/awx-operator/config/crd?ref=<VERSION>
7979
```
8080

81-
## Configuration
81+
## Custom Resource Configuration
8282

8383
The goal of adding helm configurations is to abstract out and simplify the creation of multi-resource configs. The `AWX.spec` field maps directly to the spec configs of the `AWX` resource that the operator provides, which are detailed in the [main README](https://github.com/ansible/awx-operator/blob/devel/README.md). Other sub-config can be added with the goal of simplifying more involved setups that require additional resources to be specified.
8484

@@ -246,6 +246,28 @@ AWX:
246246

247247
## Values Summary
248248

249+
### Controller
250+
The configuration of the `awx-operator-controller-manager` `Deployment` resource can be overridden by the
251+
`operator-controller` field. Any fields specified under this key will map directly onto the root hierarchy of the [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) configuration.
252+
253+
For example, to override the replicas of the controller deployment, use:
254+
255+
```yml
256+
# values
257+
operator-controller:
258+
spec:
259+
replicas: 4
260+
```
261+
262+
Similarly, to add or override annotations:
263+
```yml
264+
#values
265+
operator-controller:
266+
metadata:
267+
annotations:
268+
my-key: my-value
269+
```
270+
249271
### AWX
250272

251273
| Value | Description | Default |
@@ -263,12 +285,6 @@ AWX:
263285
|---|---|---|
264286
| `extraDeploy` | array of additional resources to be deployed (supports YAML or literal "\|") | - |
265287

266-
### Operator
267-
268-
| Value | Description | Default |
269-
|---|---|---|
270-
| `Operator.replicas` | Number of controller-manager instance replicas | `1` |
271-
272288
### customSecrets
273289

274290
| Value | Description | Default |
@@ -400,10 +416,6 @@ Where possible, defer to `AWX.spec` configs before applying the abstracted confi
400416

401417
This chart is built using the Makefile in the [awx-operator repo](https://github.com/ansible/awx-operator). Clone the repo and run `make helm-chart`. This will create the awx-operator chart in the `charts/awx-operator` directory. In this process, the contents of the `.helm/starter` directory will be added to the chart.
402418

403-
### Future Goals
404-
405-
All values under the `AWX` header are focused on configurations that use the operator. Configurations that relate to the Operator itself could be placed under an `Operator` heading, but that may add a layer of complication over current development.
406-
407419
## Chart Publishing
408420

409421
The chart is currently hosted on the gh-pages branch of the repo. During the release pipeline, the `index.yaml` stored in that branch is generated with helm chart entries from all valid tags. We are currently unable to use the `chart-releaser` pipeline due to the fact that the complete helm chart is not committed to the repo and is instead built during the release process. Therefore, the cr action is unable to compare against previous versions.

0 commit comments

Comments
 (0)