Skip to content

Commit 616cfb6

Browse files
authored
Merge pull request #5762 from jackfrancis/helm-chart-clusterapi-clusterNamespace
helm: enable clusterapi namespace autodiscovery
2 parents 165738a + dfcf7d6 commit 616cfb6

File tree

7 files changed

+49
-18
lines changed

7 files changed

+49
-18
lines changed

charts/cluster-autoscaler/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ $ helm install my-release autoscaler/cluster-autoscaler -f myvalues.yaml
224224
`cloudProvider: clusterapi` must be set, and then one or more of
225225

226226
- `autoDiscovery.clusterName`
227+
- or `autoDiscovery.namespace`
227228
- or `autoDiscovery.labels`
228229

229230
See [here](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery) for more details.
@@ -387,6 +388,7 @@ vpa:
387388
| affinity | object | `{}` | Affinity for pod assignment |
388389
| autoDiscovery.clusterName | string | `nil` | Enable autodiscovery for `cloudProvider=aws`, for groups matching `autoDiscovery.tags`. autoDiscovery.clusterName -- Enable autodiscovery for `cloudProvider=azure`, using tags defined in https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/azure/README.md#auto-discovery-setup. Enable autodiscovery for `cloudProvider=clusterapi`, for groups matching `autoDiscovery.labels`. Enable autodiscovery for `cloudProvider=gce`, but no MIG tagging required. Enable autodiscovery for `cloudProvider=magnum`, for groups matching `autoDiscovery.roles`. |
389390
| autoDiscovery.labels | list | `[]` | Cluster-API labels to match https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery |
391+
| autoDiscovery.namespace | string | `nil` | Enable autodiscovery via cluster namespace for for `cloudProvider=clusterapi` |
390392
| autoDiscovery.roles | list | `["worker"]` | Magnum node group roles to match. |
391393
| autoDiscovery.tags | list | `["k8s.io/cluster-autoscaler/enabled","k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}"]` | ASG tags to match, run through `tpl`. |
392394
| autoscalingGroups | list | `[]` | For AWS, Azure AKS or Magnum. At least one element is required if not using `autoDiscovery`. For example: <pre> - name: asg1<br /> maxSize: 2<br /> minSize: 1 </pre> For Hetzner Cloud, the `instanceType` and `region` keys are also required. <pre> - name: mypool<br /> maxSize: 2<br /> minSize: 1<br /> instanceType: CPX21<br /> region: FSN1 </pre> |

charts/cluster-autoscaler/README.md.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ $ helm install my-release autoscaler/cluster-autoscaler -f myvalues.yaml
224224
`cloudProvider: clusterapi` must be set, and then one or more of
225225

226226
- `autoDiscovery.clusterName`
227+
- or `autoDiscovery.namespace`
227228
- or `autoDiscovery.labels`
228229

229230
See [here](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery) for more details.

charts/cluster-autoscaler/templates/NOTES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or .Values.autoDiscovery.clusterName .Values.autoscalingGroups -}}
1+
{{- if or ( or .Values.autoDiscovery.clusterName .Values.autoDiscovery.namespace .Values.autoDiscovery.labels ) .Values.autoscalingGroups }}
22

33
To verify that cluster-autoscaler has started, run:
44

@@ -8,7 +8,7 @@ To verify that cluster-autoscaler has started, run:
88

99
##############################################################################
1010
#### ERROR: You must specify values for either ####
11-
#### autoDiscovery.clusterName or autoscalingGroups[] ####
11+
#### autoDiscovery or autoscalingGroups[] ####
1212
##############################################################################
1313

1414
The deployment and pod will not be created and the installation is not functional

charts/cluster-autoscaler/templates/_helpers.tpl

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ app.kubernetes.io/name: {{ include "cluster-autoscaler.name" . | quote }}
4040

4141

4242
{{/*
43-
Return labels, including instance, name and version.
43+
Return labels, including instance and name.
4444
*/}}
4545
{{- define "cluster-autoscaler.labels" -}}
4646
{{ include "cluster-autoscaler.instance-name" . }}
4747
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
48-
{{- if .Chart.AppVersion }}
49-
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
50-
{{- end }}
5148
helm.sh/chart: {{ include "cluster-autoscaler.chart" . | quote }}
5249
{{- if .Values.additionalLabels }}
5350
{{ toYaml .Values.additionalLabels }}
@@ -112,21 +109,52 @@ Return true if the priority expander is enabled
112109
{{- end -}}
113110

114111
{{/*
115-
Return the autodiscoveryparameters for clusterapi.
112+
autoDiscovery.clusterName for clusterapi.
116113
*/}}
117-
{{- define "cluster-autoscaler.capiAutodiscoveryConfig" -}}
118-
{{- if .Values.autoDiscovery.clusterName -}}
114+
{{- define "cluster-autoscaler.capiAutodiscovery.clusterName" -}}
119115
{{- print "clusterName=" -}}{{ tpl (.Values.autoDiscovery.clusterName) . }}
120116
{{- end -}}
121-
{{- if and .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels -}}
122-
{{- print "," -}}
117+
118+
{{/*
119+
autoDiscovery.namespace for clusterapi.
120+
*/}}
121+
{{- define "cluster-autoscaler.capiAutodiscovery.namespace" -}}
122+
{{- print "namespace=" }}{{ .Values.autoDiscovery.namespace -}}
123123
{{- end -}}
124-
{{- if .Values.autoDiscovery.labels -}}
124+
125+
{{/*
126+
autoDiscovery.labels for clusterapi.
127+
*/}}
128+
{{- define "cluster-autoscaler.capiAutodiscovery.labels" -}}
125129
{{- range $i, $el := .Values.autoDiscovery.labels -}}
126130
{{- if $i -}}{{- print "," -}}{{- end -}}
127131
{{- range $key, $val := $el -}}
128132
{{- $key -}}{{- print "=" -}}{{- $val -}}
129133
{{- end -}}
130134
{{- end -}}
131135
{{- end -}}
136+
137+
{{/*
138+
Return the autodiscoveryparameters for clusterapi.
139+
*/}}
140+
{{- define "cluster-autoscaler.capiAutodiscoveryConfig" -}}
141+
{{- if .Values.autoDiscovery.clusterName -}}
142+
{{ include "cluster-autoscaler.capiAutodiscovery.clusterName" . }}
143+
{{- if .Values.autoDiscovery.namespace }}
144+
{{- print "," -}}
145+
{{ include "cluster-autoscaler.capiAutodiscovery.namespace" . }}
146+
{{- end -}}
147+
{{- if .Values.autoDiscovery.labels }}
148+
{{- print "," -}}
149+
{{ include "cluster-autoscaler.capiAutodiscovery.labels" . }}
150+
{{- end -}}
151+
{{- else if .Values.autoDiscovery.namespace -}}
152+
{{ include "cluster-autoscaler.capiAutodiscovery.namespace" . }}
153+
{{- if .Values.autoDiscovery.labels }}
154+
{{- print "," -}}
155+
{{ include "cluster-autoscaler.capiAutodiscovery.labels" . }}
156+
{{- end -}}
157+
{{- else if .Values.autoDiscovery.labels -}}
158+
{{ include "cluster-autoscaler.capiAutodiscovery.labels" . }}
159+
{{- end -}}
132160
{{- end -}}

charts/cluster-autoscaler/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or ( or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels ) .Values.autoscalingGroups }}
1+
{{- if or ( or .Values.autoDiscovery.clusterName .Values.autoDiscovery.namespace .Values.autoDiscovery.labels ) .Values.autoscalingGroups }}
22
{{/* one of the above is required */}}
33
apiVersion: {{ template "deployment.apiVersion" . }}
44
kind: Deployment
@@ -99,7 +99,7 @@ spec:
9999
- --cluster-name={{ tpl (.Values.magnumClusterName) . }}
100100
{{- end }}
101101
{{- else if eq .Values.cloudProvider "clusterapi" }}
102-
{{- if or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels }}
102+
{{- if or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels .Values.autoDiscovery.namepace }}
103103
- --node-group-auto-discovery=clusterapi:{{ template "cluster-autoscaler.capiAutodiscoveryConfig" . }}
104104
{{- end }}
105105
{{- if eq .Values.clusterAPIMode "incluster-kubeconfig"}}

charts/cluster-autoscaler/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ autoDiscovery:
1616
# Enable autodiscovery for `cloudProvider=magnum`, for groups matching `autoDiscovery.roles`.
1717
clusterName: # cluster.local
1818

19+
# autoDiscovery.namespace -- Enable autodiscovery via cluster namespace for for `cloudProvider=clusterapi`
20+
namespace: # default
21+
1922
# autoDiscovery.tags -- ASG tags to match, run through `tpl`.
2023
tags:
2124
- k8s.io/cluster-autoscaler/enabled

cluster-autoscaler/cloudprovider/clusterapi/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ most likely need other command line flags. For more information you can invoke
5050

5151
## Configuring node group auto discovery
5252

53-
If you do not configure node group auto discovery, cluster autoscaler will attempt
54-
to match nodes against any scalable resources found in any namespace and belonging
55-
to any Cluster.
53+
You must configure node group auto discovery to inform cluster autoscaler which cluster in which to find for scalable node groups.
5654

5755
Limiting cluster autoscaler to only match against resources in the blue namespace
5856

@@ -454,4 +452,3 @@ here as a reference for users who might be deploying on these infrastructures.
454452
| IBM Cloud | `ibm-cloud.kubernetes.io/worker-id` | Used by the IBM Cloud Cloud Controller Manager to identify the node |
455453
| IBM Cloud | `vpc-block-csi-driver-labels` | Used by the IBM Cloud CSI driver as a target for persistent volume node affinity |
456454
| IBM Cloud | `ibm-cloud.kubernetes.io/vpc-instance-id` | Used when a VPC is in use on IBM Cloud |
457-

0 commit comments

Comments
 (0)