Skip to content

Commit 87e2372

Browse files
committed
Allow configuring of cloudconfig using helm chart values
1 parent 7a03d4d commit 87e2372

File tree

4 files changed

+44
-23
lines changed

4 files changed

+44
-23
lines changed

charts/aws-cloud-controller-manager/templates/_helpers.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
{{- .Values.nameOverride }}
33
{{- end -}}
44

5-
5+
{{- define "aws-cloud-config.name" -}}
6+
"aws-cloud-config"
7+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
{{- if .Values.cloudConfig.enabled }}
3+
apiVersion: v1
4+
data:
5+
cloudconfig.cfg: |
6+
{{- range $key, $value := .Values.cloudConfig }}
7+
{{- if not (eq $key "enabled") }}
8+
[{{ camelcase $key }}]
9+
{{- range $subKey, $subValue := $value }}
10+
{{ $subKey }}={{ $subValue }}
11+
{{- end }}
12+
{{- end }}
13+
{{- end }}
14+
kind: ConfigMap
15+
metadata:
16+
name: {{- include "aws-cloud-config.name" . }}
17+
{{- end }}

charts/aws-cloud-controller-manager/templates/daemonset.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,42 @@ spec:
3232
hostNetwork: true
3333
{{- end }}
3434
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }}
35-
{{- with .Values.imagePullSecrets }}
36-
imagePullSecrets:
37-
{{- toYaml . | nindent 8 }}
38-
{{- end }}
3935
containers:
4036
- name: {{ .Chart.Name }}
4137
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
38+
{{- $args := .Values.args }}
39+
{{- if and (.Values.cloudConfig.enabled) (not (contains "--cloud-config" (cat $args))) }}
40+
{{- $args = append $args "--cloud-config=/etc/cloudconfig.cfg" }}
41+
{{- end }}
4242
args:
43-
{{- range .Values.args }}
43+
{{- range $args }}
4444
- {{ . }}
4545
{{- end }}
4646
resources:
4747
{{- toYaml .Values.resources | nindent 12 }}
4848
env: {{- toYaml .Values.env | nindent 12 }}
4949
securityContext:
5050
{{- toYaml .Values.securityContext | nindent 12 }}
51-
{{- with .Values.extraVolumeMounts }}
51+
{{- if or (.Values.cloudConfig.enabled) (.Values.extraVolumeMounts) }}
5252
volumeMounts:
53+
{{- if .Values.cloudConfig.enabled }}
54+
- name: {{ include "aws-cloud-config.name" . }}
55+
mountPath: /etc/cloudconfig.cfg
56+
subPath: cloudconfig.cfg
57+
{{- end }}
58+
{{- with .Values.extraVolumeMounts}}
5359
{{- toYaml .| nindent 12 }}
5460
{{- end }}
55-
{{- with .Values.extraVolumes }}
61+
{{- end }}
62+
{{- if or (.Values.cloudConfig.enabled) (.Values.extraVolumes) }}
5663
volumes:
64+
{{- with .Values.extraVolumes}}
5765
{{- toYaml . | nindent 8 }}
5866
{{- end }}
67+
{{- end }}
68+
{{- if .Values.cloudConfig.enabled }}
69+
- name: {{- include "aws-cloud-config.name" . }}
70+
configMap:
71+
name: {{- include "aws-cloud-config.name" . }}
72+
{{- end }}
5973
---

charts/aws-cloud-controller-manager/values.yaml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ image:
88
repository: registry.k8s.io/provider-aws/cloud-controller-manager
99
tag: v1.27.1
1010

11-
# Specify image pull secrets
12-
imagePullSecrets: []
13-
1411
# nameOverride overrides `cloud-controller-manager.fullname`
1512
nameOverride: "aws-cloud-controller-manager"
1613

@@ -98,18 +95,6 @@ clusterRoleRules:
9895
- serviceaccounts/token
9996
verbs:
10097
- create
101-
- apiGroups:
102-
- authentication.k8s.io
103-
resources:
104-
- tokenreviews
105-
verbs:
106-
- create
107-
- apiGroups:
108-
- authorization.k8s.io
109-
resources:
110-
- subjectaccessreviews
111-
verbs:
112-
- create
11398

11499
# resources -- Pod resource requests and limits.
115100
resources:
@@ -153,3 +138,6 @@ roleName: extension-apiserver-authentication-reader
153138

154139
extraVolumes: []
155140
extraVolumeMounts: []
141+
142+
cloudConfig:
143+
enabled: false

0 commit comments

Comments
 (0)