Skip to content

Commit 13dba17

Browse files
authored
Merge pull request #7936 from fcrespofastly/allow_tpl_on_various_parts_of_the_chart
allow `tpl` on common metadata to DRY
2 parents 19cb117 + 460797b commit 13dba17

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

charts/cluster-autoscaler/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ name: cluster-autoscaler
1111
sources:
1212
- https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler
1313
type: application
14-
version: 9.46.5
14+
version: 9.46.6

charts/cluster-autoscaler/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ $ helm install my-release autoscaler/cluster-autoscaler \
183183

184184
Note that `your-ig-prefix` should be a _prefix_ matching one or more MIGs, and _not_ the full name of the MIG. For example, to match multiple instance groups - `k8s-node-group-a-standard`, `k8s-node-group-b-gpu`, you would use a prefix of `k8s-node-group-`.
185185

186+
Prefixes will be rendered using `tpl` function so you can use any value of your choice if that's a valid prefix. For instance (ignore escaping characters): `gke-{{ .Values.autoDiscovery.clusterName }}`
187+
186188
In the event you want to explicitly specify MIGs instead of using auto-discovery, set members of the `autoscalingGroups` array directly - e.g.
187189

188190
```
@@ -326,7 +328,14 @@ For Kubernetes clusters that use Amazon EKS, the service account can be configur
326328

327329
In order to accomplish this, you will first need to create a new IAM role with the above mentions policies. Take care in [configuring the trust relationship](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html#iam-role-configuration) to restrict access just to the service account used by cluster autoscaler.
328330

329-
Once you have the IAM role configured, you would then need to `--set rbac.serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=arn:aws:iam::123456789012:role/MyRoleName` when installing.
331+
Once you have the IAM role configured, you would then need to `--set rbac.serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=arn:aws:iam::123456789012:role/MyRoleName` when installing. Alternatively, you can embed templates in values (ignore escaping characters):
332+
333+
```yaml
334+
rbac:
335+
serviceAccount:
336+
annotations:
337+
eks.amazonaws.com/role-arn: "{{ .Values.aws.myroleARN }}"
338+
```
330339

331340
### Azure - Using azure workload identity
332341

charts/cluster-autoscaler/README.md.gotmpl

+10-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ $ helm install my-release autoscaler/cluster-autoscaler \
183183

184184
Note that `your-ig-prefix` should be a _prefix_ matching one or more MIGs, and _not_ the full name of the MIG. For example, to match multiple instance groups - `k8s-node-group-a-standard`, `k8s-node-group-b-gpu`, you would use a prefix of `k8s-node-group-`.
185185

186+
Prefixes will be rendered using `tpl` function so you can use any value of your choice if that's a valid prefix. For instance (ignore escaping characters): `gke-{{`{{ .Values.autoDiscovery.clusterName }}`}}`
187+
186188
In the event you want to explicitly specify MIGs instead of using auto-discovery, set members of the `autoscalingGroups` array directly - e.g.
187189

188190
```
@@ -326,7 +328,14 @@ For Kubernetes clusters that use Amazon EKS, the service account can be configur
326328

327329
In order to accomplish this, you will first need to create a new IAM role with the above mentions policies. Take care in [configuring the trust relationship](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html#iam-role-configuration) to restrict access just to the service account used by cluster autoscaler.
328330

329-
Once you have the IAM role configured, you would then need to `--set rbac.serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=arn:aws:iam::123456789012:role/MyRoleName` when installing.
331+
Once you have the IAM role configured, you would then need to `--set rbac.serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=arn:aws:iam::123456789012:role/MyRoleName` when installing. Alternatively, you can embed templates in values (ignore escaping characters):
332+
333+
```yaml
334+
rbac:
335+
serviceAccount:
336+
annotations:
337+
eks.amazonaws.com/role-arn: "{{`{{ .Values.aws.myroleARN `}}}}"
338+
```
330339

331340
### Azure - Using azure workload identity
332341

charts/cluster-autoscaler/templates/deployment.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ spec:
8686
{{- else if eq .Values.cloudProvider "gce" }}
8787
{{- if .Values.autoscalingGroupsnamePrefix }}
8888
{{- range .Values.autoscalingGroupsnamePrefix }}
89-
- --node-group-auto-discovery=mig:namePrefix={{ .name }},min={{ .minSize }},max={{ .maxSize }}
89+
- --node-group-auto-discovery=mig:namePrefix={{ tpl .name $ }},min={{ .minSize }},max={{ .maxSize }}
9090
{{- end }}
9191
{{- end }}
9292
{{- if eq .Values.cloudProvider "oci" }}
@@ -144,9 +144,9 @@ spec:
144144
valueFrom:
145145
fieldRef:
146146
fieldPath: spec.serviceAccountName
147-
{{- if and (eq .Values.cloudProvider "aws") (ne .Values.awsRegion "") }}
147+
{{- if and (eq .Values.cloudProvider "aws") (ne (tpl .Values.awsRegion $) "") }}
148148
- name: AWS_REGION
149-
value: "{{ .Values.awsRegion }}"
149+
value: "{{ tpl .Values.awsRegion $ }}"
150150
{{- if .Values.awsAccessKeyID }}
151151
- name: AWS_ACCESS_KEY_ID
152152
valueFrom:

charts/cluster-autoscaler/templates/serviceaccount.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ metadata:
66
{{ include "cluster-autoscaler.labels" . | indent 4 }}
77
name: {{ template "cluster-autoscaler.serviceAccountName" . }}
88
namespace: {{ .Release.Namespace }}
9-
{{- if .Values.rbac.serviceAccount.annotations }}
10-
annotations: {{ toYaml .Values.rbac.serviceAccount.annotations | nindent 4 }}
9+
10+
{{- with .Values.rbac.serviceAccount.annotations }}
11+
annotations:
12+
{{- range $k, $v := . }}
13+
{{- printf "%s: %s" (tpl $k $) (tpl $v $) | nindent 4 }}
14+
{{- end }}
1115
{{- end }}
1216
automountServiceAccountToken: {{ .Values.rbac.serviceAccount.automountServiceAccountToken }}
1317
{{- end }}

0 commit comments

Comments
 (0)