Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add priority to dex jobs #1439

Merged
merged 5 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/dex/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: dex
version: 2.12.2
version: 2.12.3
appVersion: 2.35.2
description: Dex
keywords:
Expand Down
3 changes: 3 additions & 0 deletions stable/dex/templates/job-grpc-certs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
{{ toYaml .Values.certs.grpc.pod.annotations | trim | indent 8 }}
{{- end }}
spec:
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- if .Values.certs.securityContext.enabled }}
securityContext:
runAsUser: {{ .Values.certs.securityContext.runAsUser }}
Expand Down
77 changes: 77 additions & 0 deletions stable/dex/templates/pre-upgrade-delete-jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{- if or .Values.certs.grpc.create .Values.certs.web.create }}
# For upgrades from 2.11.1 to 2.12.3 (AKA DKP 2.5 to DKP 2.6)
# To avoid unnecessarily rerunning the Jobs during upgrade within 2.6, select using the helm chart
# version label to only delete the Jobs if they are on dex 2.11.1 (version shipped in DKP 2.5).
# 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 the pre-upgrade hook.
---
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: ["batch"]
resources: ["jobs"]
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,helm.sh/chart=dex-2.11.1' --cascade=orphan -n {{ .Release.Namespace }}
cbuto marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
3 changes: 3 additions & 0 deletions stable/dex/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ initContainers: []

priorityClassName: ""

# kubectl image to use for jobs
kubectlImage: "bitnami/kubectl:1.26.4"

tolerations: []
# - key: CriticalAddonsOnly
# operator: Exists
Expand Down