Skip to content

Commit

Permalink
Allow configuring of cloudconfig using helm chart values
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewuolle committed Dec 18, 2024
1 parent 7a03d4d commit 6d8b4da
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
3 changes: 2 additions & 1 deletion charts/aws-cloud-controller-manager/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
{{- .Values.nameOverride }}
{{- end -}}


{{- define "aws-cloud-config.name" }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/aws-cloud-controller-manager/templates/cloudconfigmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
{{- if .Values.cloudConfig.enabled }}
apiVersion: v1
data:
cloudconfig.cfg: |
{{- range $key, $value := .Values.cloudConfig }}
{{- if not (eq $key "enabled") }}
[{{ camelcase $key }}]
{{- range $subKey, $subValue := $value }}
{{ $subKey }}={{ $subValue }}
{{- end }}
{{- end }}
{{- end }}
kind: ConfigMap
metadata:
name: {{ template "aws-cloud-config.name" . }}
{{- end }}
28 changes: 21 additions & 7 deletions charts/aws-cloud-controller-manager/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,42 @@ spec:
hostNetwork: true
{{- end }}
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
{{- $args := .Values.args }}
{{- if and (.Values.cloudConfig.enabled) (not (contains "--cloud-config" (cat $args))) }}
{{- $args = append $args "--cloud-config=/etc/cloudconfig.cfg" }}
{{- end }}
args:
{{- range .Values.args }}
{{- range $args }}
- {{ . }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env: {{- toYaml .Values.env | nindent 12 }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.extraVolumeMounts }}
{{- if or (.Values.cloudConfig.enabled) (.Values.extraVolumeMounts) }}
volumeMounts:
{{- if .Values.cloudConfig.enabled }}
- name: {{ template "aws-cloud-config.name" . }}
mountPath: /etc/cloudconfig.cfg
subPath: cloudconfig.cfg
{{- end }}
{{- with .Values.extraVolumeMounts}}
{{- toYaml .| nindent 12 }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- end }}
{{- if or (.Values.cloudConfig.enabled) (.Values.extraVolumes) }}
volumes:
{{- with .Values.extraVolumes}}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.cloudConfig.enabled }}
- name: {{ template "aws-cloud-config.name" . }}
configMap:
name: {{ template "aws-cloud-config.name" . }}
{{- end }}
---
18 changes: 3 additions & 15 deletions charts/aws-cloud-controller-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ image:
repository: registry.k8s.io/provider-aws/cloud-controller-manager
tag: v1.27.1

# Specify image pull secrets
imagePullSecrets: []

# nameOverride overrides `cloud-controller-manager.fullname`
nameOverride: "aws-cloud-controller-manager"

Expand Down Expand Up @@ -98,18 +95,6 @@ clusterRoleRules:
- serviceaccounts/token
verbs:
- create
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create

# resources -- Pod resource requests and limits.
resources:
Expand Down Expand Up @@ -153,3 +138,6 @@ roleName: extension-apiserver-authentication-reader

extraVolumes: []
extraVolumeMounts: []

cloudConfig:
enabled: false

0 comments on commit 6d8b4da

Please sign in to comment.