Skip to content

Commit 5721fba

Browse files
authored
[helm] Add PDB and update label patterns (#463)
1 parent a0f05f0 commit 5721fba

File tree

10 files changed

+47
-28
lines changed

10 files changed

+47
-28
lines changed

config/helm/aws-node-termination-handler/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Parameter | Description | Default
9999
`managedAsgTag` | The tag to ensure is on a node if checkASGTagBeforeDraining is true | `aws-node-termination-handler/managed`
100100
`workers` | The maximum amount of parallel event processors | `10`
101101
`replicas` | The number of replicas in the NTH deployment when using queue-processor mode (NOTE: increasing replicas may cause duplicate webhooks since NTH pods are stateless) | `1`
102+
`podDisruptionBudget` | Limit the disruption for controller pods, requires at least 2 controller replicas | `{}`
102103

103104
### AWS Node Termination Handler - IMDS Mode Configuration
104105

config/helm/aws-node-termination-handler/templates/_helpers.tpl

+9-3
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,22 @@ Name will not exceed 63 characters.
3636
Common labels
3737
*/}}
3838
{{- define "aws-node-termination-handler.labels" -}}
39-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
4039
helm.sh/chart: {{ include "aws-node-termination-handler.chart" . }}
41-
app.kubernetes.io/instance: {{ .Release.Name }}
42-
k8s-app: aws-node-termination-handler
40+
{{ include "aws-node-termination-handler.selectorLabels" . }}
4341
{{- if .Chart.AppVersion }}
4442
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4543
{{- end }}
4644
app.kubernetes.io/managed-by: {{ .Release.Service }}
4745
{{- end -}}
4846

47+
{{/*
48+
Selector labels
49+
*/}}
50+
{{- define "aws-node-termination-handler.selectorLabels" -}}
51+
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
52+
app.kubernetes.io/instance: {{ .Release.Name }}
53+
{{- end -}}
54+
4955
{{/*
5056
Create chart name and version as used by the chart label.
5157
*/}}

config/helm/aws-node-termination-handler/templates/daemonset.linux.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ include "aws-node-termination-handler.fullname" . }}
66
namespace: {{ .Release.Namespace }}
77
labels:
8-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
8+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
99
spec:
1010
{{- if (or .Values.updateStrategy .Values.linuxUpdateStrategy) }}
1111
updateStrategy:
@@ -18,8 +18,7 @@ spec:
1818
{{- end }}
1919
selector:
2020
matchLabels:
21-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
22-
app.kubernetes.io/instance: {{ .Release.Name }}
21+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 6 }}
2322
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux
2423
template:
2524
metadata:
@@ -30,8 +29,7 @@ spec:
3029
{{- end }}
3130
{{- end }}
3231
labels:
33-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
34-
app.kubernetes.io/instance: {{ .Release.Name }}
32+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }}
3533
k8s-app: aws-node-termination-handler
3634
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux
3735
{{- range $key, $value := (mergeOverwrite (dict) .Values.podLabels .Values.linuxPodLabels) }}

config/helm/aws-node-termination-handler/templates/daemonset.windows.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ include "aws-node-termination-handler.fullname.windows" . }}
66
namespace: {{ .Release.Namespace }}
77
labels:
8-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
8+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
99
spec:
1010
{{- if (or .Values.updateStrategy .Values.windowsUpdateStrategy) }}
1111
updateStrategy:
@@ -18,8 +18,7 @@ spec:
1818
{{- end }}
1919
selector:
2020
matchLabels:
21-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
22-
app.kubernetes.io/instance: {{ .Release.Name }}
21+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 6 }}
2322
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: windows
2423
template:
2524
metadata:
@@ -30,8 +29,7 @@ spec:
3029
{{- end }}
3130
{{- end }}
3231
labels:
33-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
34-
app.kubernetes.io/instance: {{ .Release.Name }}
32+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }}
3533
k8s-app: aws-node-termination-handler
3634
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: windows
3735
{{- range $key, $value := (mergeOverwrite (dict) .Values.podLabels .Values.windowsPodLabels) }}

config/helm/aws-node-termination-handler/templates/deployment.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ metadata:
55
name: {{ include "aws-node-termination-handler.fullname" . }}
66
namespace: {{ .Release.Namespace }}
77
labels:
8-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
8+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
99
spec:
1010
replicas: {{ .Values.replicas }}
1111
selector:
1212
matchLabels:
13-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
14-
app.kubernetes.io/instance: {{ .Release.Name }}
13+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 6 }}
1514
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux
1615
template:
1716
metadata:
@@ -20,8 +19,7 @@ spec:
2019
{{ $key }}: {{ $value | quote }}
2120
{{- end }}
2221
labels:
23-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
24-
app.kubernetes.io/instance: {{ .Release.Name }}
22+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }}
2523
k8s-app: aws-node-termination-handler
2624
{{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux
2725
{{- range $key, $value := .Values.podLabels }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if and .Values.enableSqsTerminationDraining (and .Values.podDisruptionBudget (gt (int .Values.replicas) 1)) }}
2+
apiVersion: policy/v1beta1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ include "aws-node-termination-handler.fullname" . }}
6+
labels:
7+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 6 }}
12+
{{- toYaml .Values.podDisruptionBudget | nindent 2 }}
13+
{{- end }}

config/helm/aws-node-termination-handler/templates/podmonitor.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ metadata:
99
namespace: {{ .Release.Namespace }}
1010
{{- end }}
1111
labels:
12-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
13-
{{- with .Values.podMonitor.labels }}
14-
{{ toYaml . | indent 4 }}
15-
{{- end }}
12+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
13+
{{- with .Values.podMonitor.labels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
1616
spec:
1717
jobLabel: {{ include "aws-node-termination-handler.name" . }}
1818
namespaceSelector:
@@ -25,5 +25,5 @@ spec:
2525
sampleLimit: {{ .Values.podMonitor.sampleLimit }}
2626
selector:
2727
matchLabels:
28-
app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . }}
28+
{{- include "aws-node-termination-handler.selectorLabels" . | nindent 6 }}
2929
{{- end }}

config/helm/aws-node-termination-handler/templates/psp.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: PodSecurityPolicy
44
metadata:
55
name: {{ template "aws-node-termination-handler.fullname" . }}
66
labels:
7-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
7+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
88
annotations:
99
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*'
1010
spec:
@@ -38,7 +38,7 @@ metadata:
3838
name: {{ template "aws-node-termination-handler.fullname" . }}-psp
3939
namespace: {{ .Release.Namespace }}
4040
labels:
41-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
41+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
4242
rules:
4343
- apiGroups: ['policy']
4444
resources: ['podsecuritypolicies']
@@ -52,7 +52,7 @@ metadata:
5252
name: {{ template "aws-node-termination-handler.fullname" . }}-psp
5353
namespace: {{ .Release.Namespace }}
5454
labels:
55-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
55+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
5656
roleRef:
5757
apiGroup: rbac.authorization.k8s.io
5858
kind: Role

config/helm/aws-node-termination-handler/templates/serviceaccount.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ metadata:
66
namespace: {{ .Release.Namespace }}
77
{{- with .Values.serviceAccount.annotations }}
88
annotations:
9-
{{ toYaml . | indent 4 }}
9+
{{- toYaml . | nindent 4 }}
1010
{{- end }}
1111
labels:
12-
{{ include "aws-node-termination-handler.labels" . | indent 4 }}
12+
{{- include "aws-node-termination-handler.labels" . | nindent 4 }}
1313
{{- end -}}

config/helm/aws-node-termination-handler/values.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ workers: 10
219219

220220
# The number of replicas in the NTH deployment when using queue-processor mode (NOTE: increasing this may cause duplicate webhooks since NTH pods are stateless)
221221
replicas: 1
222+
223+
# podDisruptionBudget specifies the disruption budget for the controller pods.
224+
# Disruption budget will be configured only when the replicaCount is greater than 1
225+
podDisruptionBudget: {}
226+
# maxUnavailable: 1

0 commit comments

Comments
 (0)