-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add pre-upgrade hook to delete jobs
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# For upgrades to 2.12.3+. | ||
# Delete the Jobs created by the dex chart prior to upgrading. Priority class was added | ||
# to Job specs, which is an immutable field and requires the Job to be | ||
# deleted and recreated. After this release, we can remove this pre-upgrade hook because | ||
# TTL will be set on the Job to automatically clean it up after it runs. | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "dex.fullname" . }}-pre-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
helm.sh/hook: pre-upgrade | ||
helm.sh/hook-weight: "-5" | ||
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ template "dex.fullname" . }}-pre-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": pre-upgrade | ||
"helm.sh/hook-weight": "-4" | ||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation | ||
rules: | ||
- apiGroups: ["apps"] | ||
resources: ["deployments"] | ||
verbs: ["get", "watch", "list", "delete"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ template "dex.fullname" . }}-pre-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": pre-upgrade | ||
"helm.sh/hook-weight": "-4" | ||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ template "dex.fullname" . }}-pre-upgrade | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "dex.fullname" . }}-pre-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "dex.fullname" . }}-delete-jobs | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": pre-upgrade | ||
"helm.sh/hook-weight": "4" | ||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation | ||
spec: | ||
template: | ||
metadata: | ||
name: {{ template "dex.fullname" . }}-delete-jobs | ||
spec: | ||
serviceAccountName: {{ template "dex.fullname" . }}-pre-upgrade | ||
restartPolicy: OnFailure | ||
{{- if .Values.priorityClassName }} | ||
priorityClassName: "{{ .Values.priorityClassName }}" | ||
{{- end }} | ||
containers: | ||
- name: kubectl | ||
image: "{{ .Values.kubectlImage }}" | ||
command: | ||
- sh | ||
- -c | ||
- kubectl delete jobs.batch -l 'app.kubernetes.io/component in (job-grpc-certs, job-web-certs),app.kubernetes.io/name=dex' --cascade=orphan -n {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters