Skip to content

Commit

Permalink
[stable/cluster-autoscaler] Use labels recommended by Helm (helm#15695)
Browse files Browse the repository at this point in the history
See https://helm.sh/docs/chart_best_practices/#standard-labels

Since the Deployment's selector is immutable, this is breaking change and will require a deletion and recreation, hence the major version bump.

Signed-off-by: Peter Rifel <[email protected]>
  • Loading branch information
rifelpet authored and gaida committed Oct 3, 2019
1 parent 3b1aaff commit 169bd8e
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 43 deletions.
2 changes: 1 addition & 1 deletion stable/cluster-autoscaler/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
description: Scales worker nodes within autoscaling groups.
icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png
name: cluster-autoscaler
version: 1.1.0
version: 2.0.0
appVersion: 1.13.1
home: https://github.com/kubernetes/autoscaler
sources:
Expand Down
11 changes: 11 additions & 0 deletions stable/cluster-autoscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ This chart bootstraps a cluster-autoscaler deployment on a [Kubernetes](http://k
- Azure AKS specific Prerequisites:
- Kubernetes 1.10+ with RBAC-enabled

## Upgrading from <2.X

In order to upgrade to chart version to 2.X from 1.X or 0.X, deleting the old helm release first is required.

```console
$ helm del --purge my-release
```

Once the old release is deleted, the new 2.X release can be installed using the standard instructions.
Note that autoscaling will not occur during the time between deletion and installation.

## Installing the Chart

**By default, no deployment is created and nothing will autoscale**.
Expand Down
25 changes: 25 additions & 0 deletions stable/cluster-autoscaler/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,28 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cluster-autoscaler.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return instance and name labels.
*/}}
{{- define "cluster-autoscaler.instance-name" -}}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/name: {{ include "cluster-autoscaler.name" . | quote }}
{{- end -}}


{{/*
Return labels, including instance and name.
*/}}
{{- define "cluster-autoscaler.labels" -}}
{{ include "cluster-autoscaler.instance-name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
helm.sh/chart: {{ include "cluster-autoscaler.chart" . | quote }}
{{- end -}}
5 changes: 1 addition & 4 deletions stable/cluster-autoscaler/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
rules:
- apiGroups:
Expand Down
5 changes: 1 addition & 4 deletions stable/cluster-autoscaler/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
11 changes: 3 additions & 8 deletions stable/cluster-autoscaler/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ apiVersion: {{ .Values.deployment.apiVersion }}
kind: Deployment
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "cluster-autoscaler.name" . }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 6 }}
{{- end }}
Expand All @@ -25,8 +21,7 @@ spec:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "cluster-autoscaler.name" . }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.instance-name" . | indent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
Expand Down
8 changes: 2 additions & 6 deletions stable/cluster-autoscaler/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
spec:
selector:
matchLabels:
app: {{ template "cluster-autoscaler.name" . }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
{{ .Values.podDisruptionBudget | indent 2 }}
{{- end -}}
5 changes: 1 addition & 4 deletions stable/cluster-autoscaler/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
rules:
- apiGroups:
Expand Down
5 changes: 1 addition & 4 deletions stable/cluster-autoscaler/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
8 changes: 2 additions & 6 deletions stable/cluster-autoscaler/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ metadata:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
spec:
{{- if .Values.service.clusterIP }}
Expand All @@ -32,6 +29,5 @@ spec:
targetPort: 8085
name: {{ .Values.service.portName }}
selector:
app: {{ template "cluster-autoscaler.name" . }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.instance-name" . | indent 4 }}
type: "{{ .Values.service.type }}"
5 changes: 1 addition & 4 deletions stable/cluster-autoscaler/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ template "cluster-autoscaler.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.labels" . | indent 4 }}
name: {{ template "cluster-autoscaler.fullname" . }}
{{- end -}}
3 changes: 1 addition & 2 deletions stable/cluster-autoscaler/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ metadata:
spec:
selector:
matchLabels:
app: {{ template "cluster-autoscaler.name" . }}
release: {{ .Release.Name }}
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
endpoints:
- port: {{ .Values.service.portName }}
interval: {{ .Values.serviceMonitor.interval }}
Expand Down

0 comments on commit 169bd8e

Please sign in to comment.