Skip to content

Commit e8ec3d0

Browse files
authored
add feature gates support in Helm templates (#531)
Issue #, if available: N/A, but related to aws-controllers-k8s/runtime#151 Description of changes: Adds optional support for feature gates in Helm templates. A top-level key of `featureGates` has been added to the default values file template, and the optional command-line argument has been appended to the deployment template. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent f0a0f42 commit e8ec3d0

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

templates/helm/templates/_helpers.tpl.tpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@
5151
{{ "{{/* The rules a of ClusterRole or Role */}}" }}
5252
{{ DefineTemplate "rbac-rules" }}
5353
SEDREPLACERULES
54-
{{ "{{- end }}" }}
54+
{{ "{{- end }}" }}
55+
56+
{{ "{{/* Convert k/v map to string like: \"key1=value1,key2=value2,...\" */}}" }}
57+
{{ DefineTemplate "feature-gates" }}
58+
{{ "{{- $list := list -}}" }}
59+
{{ "{{- range $k, $v := .Values.featureGates -}}" }}
60+
{{ "{{- $list = append $list (printf \"%s=%s\" $k ( $v | toString)) -}}" }}
61+
{{ "{{- end -}}" }}
62+
{{ "{{ join \",\" $list }}" }}
63+
{{ "{{- end -}}" }}

templates/helm/templates/deployment.yaml.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ spec:
7979
{{ "{{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }}" }}
8080
- --reconcile-resource-max-concurrent-syncs
8181
- {{ "\"$(RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }})\"" }}
82+
{{ "{{- end }}" }}
83+
{{ "{{- if .Values.featureGates}}" }}
84+
- --feature-gates
85+
- "$(FEATURE_GATES)"
8286
{{ "{{- end }}" }}
8387
image: {{ "{{ .Values.image.repository }}:{{ .Values.image.tag }}" }}
8488
imagePullPolicy: {{ "{{ .Values.image.pullPolicy }}" }}
@@ -122,6 +126,10 @@ spec:
122126
{{ "{{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }}" }}
123127
- name: {{ "RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }}" }}
124128
value: {{ "{{ $key }}={{ $value }}" }}
129+
{{ "{{- end }}" }}
130+
{{ "{{- if .Values.featureGates}}" }}
131+
- name: FEATURE_GATES
132+
value: {{ IncludeTemplate "feature-gates" }}
125133
{{ "{{- end }}" }}
126134
{{ "{{- if .Values.aws.credentials.secretName }}" }}
127135
- name: AWS_SHARED_CREDENTIALS_FILE

templates/helm/values.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@
268268
"type": "object"
269269
}
270270
},
271+
"featureGates": {
272+
"description": "Feature gates settings",
273+
"type": "object",
274+
"additionalProperties": {
275+
"type": "boolean"
276+
}
277+
},
271278
"required": [
272279
"image",
273280
"deployment",

templates/helm/values.yaml.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,10 @@ leaderElection:
153153
# will attempt to use the namespace of the service account mounted to the Controller
154154
# pod.
155155
namespace: ""
156+
157+
# Configuration for feature gates. These are optional controller features that
158+
# can be individually enabled ("true") or disabled ("false") by adding key/value
159+
# pairs below.
160+
featureGates: {}
161+
# featureGate1: true
162+
# featureGate2: false

0 commit comments

Comments
 (0)