Skip to content

Commit

Permalink
[v14] Adding extra pod labels to post-upgrade and post-delete hook jo…
Browse files Browse the repository at this point in the history
…b pods (#46236)

* Manual backport of PR 46029 to v14

* Re-run jobs from empty commit
  • Loading branch information
mvbrock authored Sep 6, 2024
1 parent 236d9fa commit 20e16bd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
9 changes: 9 additions & 0 deletions examples/chart/teleport-kube-agent/templates/delete_hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ spec:
template:
metadata:
name: {{ .Release.Name }}-delete-hook
{{- if .Values.annotations.pod }}
annotations:
{{- toYaml .Values.annotations.pod | nindent 8 }}
{{- end }}
labels:
app: {{ .Release.Name }}
{{- if .Values.extraLabels.pod }}
{{- toYaml .Values.extraLabels.pod | nindent 8 }}
{{- end }}
spec:
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
9 changes: 9 additions & 0 deletions examples/chart/teleport-kube-agent/templates/hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ spec:
template:
metadata:
name: {{ .Release.Name }}-hook
{{- if .Values.annotations.pod }}
annotations:
{{- toYaml .Values.annotations.pod | nindent 8 }}
{{- end }}
labels:
app: {{ .Release.Name }}
{{- if .Values.extraLabels.pod }}
{{- toYaml .Values.extraLabels.pod | nindent 8 }}
{{- end }}
spec:
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ should not create ServiceAccount for post-delete hook if serviceAccount.create i
spec:
template:
metadata:
labels:
app: RELEASE-NAME
name: RELEASE-NAME-delete-hook
spec:
containers:
Expand Down
17 changes: 17 additions & 0 deletions examples/chart/teleport-kube-agent/tests/job_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,20 @@ tests:
apiVersion: rbac.authorization.k8s.io/v1
- matchSnapshot:
path: spec.template.spec

- it: should contain pod labels in the Job's pod spec if extraLabels.pod is set
template: delete_hook.yaml
# documentIndex: 0=ServiceAccount 1=Role 2=RoleBinding 3=Job
documentIndex: 3
values:
- ../.lint/backwards-compatibility.yaml
set:
extraLabels:
pod:
testLabel: testValue
asserts:
- equal:
path: spec.template.metadata.labels
value:
app: RELEASE-NAME
testLabel: testValue
2 changes: 1 addition & 1 deletion examples/chart/teleport-kube-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ extraLabels:
deployment: {}
# Labels to set on the post-delete Job created by the chart.
job: {}
# Labels for each Pod in the Deployment/StatefulSet
# Labels for each Pod in the Deployment, StatefulSet, or Job
pod: {}
# Labels for the Pod Disruption Budget (ignored when disabled)
podDisruptionBudget: {}
Expand Down

0 comments on commit 20e16bd

Please sign in to comment.