From c0518bf552677a4947eb36da1a6c9068009d9756 Mon Sep 17 00:00:00 2001
From: Henrik Gerdes <hegerdes@outlook.de>
Date: Sun, 8 Sep 2024 15:30:40 +0200
Subject: [PATCH] feat: allow setting init containers for cluster-autoscaler

Signed-off-by: Henrik Gerdes <hegerdes@outlook.de>
---
 charts/cluster-autoscaler/Chart.yaml                | 2 +-
 charts/cluster-autoscaler/README.md                 | 1 +
 charts/cluster-autoscaler/templates/deployment.yaml | 4 ++++
 charts/cluster-autoscaler/values.yaml               | 3 +++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/charts/cluster-autoscaler/Chart.yaml b/charts/cluster-autoscaler/Chart.yaml
index 9f74a0b55186..7c0aef984597 100644
--- a/charts/cluster-autoscaler/Chart.yaml
+++ b/charts/cluster-autoscaler/Chart.yaml
@@ -11,4 +11,4 @@ name: cluster-autoscaler
 sources:
   - https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler
 type: application
-version: 9.37.0
+version: 9.38.0
diff --git a/charts/cluster-autoscaler/README.md b/charts/cluster-autoscaler/README.md
index ac6fef8e5665..7a81737e9ccb 100644
--- a/charts/cluster-autoscaler/README.md
+++ b/charts/cluster-autoscaler/README.md
@@ -431,6 +431,7 @@ vpa:
 | image.pullSecrets | list | `[]` | Image pull secrets |
 | image.repository | string | `"registry.k8s.io/autoscaling/cluster-autoscaler"` | Image repository |
 | image.tag | string | `"v1.30.0"` | Image tag |
+| initContainers | list | `[]` | Any additional init containers. |
 | kubeTargetVersionOverride | string | `""` | Allow overriding the `.Capabilities.KubeVersion.GitVersion` check. Useful for `helm template` commands. |
 | kwokConfigMapName | string | `"kwok-provider-config"` | configmap for configuring kwok provider |
 | magnumCABundlePath | string | `"/etc/kubernetes/ca-bundle.crt"` | Path to the host's CA bundle, from `ca-file` in the cloud-config file. |
diff --git a/charts/cluster-autoscaler/templates/deployment.yaml b/charts/cluster-autoscaler/templates/deployment.yaml
index 1b06186bf212..4850c7903805 100644
--- a/charts/cluster-autoscaler/templates/deployment.yaml
+++ b/charts/cluster-autoscaler/templates/deployment.yaml
@@ -46,6 +46,10 @@ spec:
       {{- if .Values.hostNetwork }}
       hostNetwork: {{ .Values.hostNetwork }}
       {{- end }}
+      {{- with .Values.initContainers }}
+      initContainers:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
       containers:
         - name: {{ template "cluster-autoscaler.name" . }}
           image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
diff --git a/charts/cluster-autoscaler/values.yaml b/charts/cluster-autoscaler/values.yaml
index ac19825e0881..47f64b6cb43b 100644
--- a/charts/cluster-autoscaler/values.yaml
+++ b/charts/cluster-autoscaler/values.yaml
@@ -226,6 +226,9 @@ extraVolumeSecrets: {}
   #     - key: subkey
   #       path: mypath
 
+# initContainers -- Any additional init containers.
+initContainers: []
+
 # fullnameOverride -- String to fully override `cluster-autoscaler.fullname` template.
 fullnameOverride: ""