Skip to content

Commit

Permalink
feat: add post-install,post-upgrade delete hook to delete old webhook… (
Browse files Browse the repository at this point in the history
#513)

Signed-off-by: Fabrizio Sestito <[email protected]>
  • Loading branch information
fabriziosestito authored Sep 3, 2024
1 parent de05eff commit aab7910
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions charts/kubewarden-controller/templates/post-install-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,45 @@ spec:
securityContext:
{{ toYaml .Values.preDeleteHook.containerSecurityContext | indent 12 }}
{{- end }}

---
# Delete pre 1.17 webhook certificates secret.
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-delete-pre-1-17-webhook-server-cert"
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- include "kubewarden-controller.annotations" . | nindent 4 }}
spec:
template:
metadata:
name: "{{ .Release.Name }}-delete-pre-1-17-webhook-server-cert"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
{{- include "kubewarden-controller.annotations" . | nindent 8 }}
spec:
restartPolicy: OnFailure
serviceAccountName: {{ include "kubewarden-controller.serviceAccountName" . }}
{{- if .Values.preDeleteHook.podSecurityContext }}
securityContext:
{{ toYaml .Values.preDeleteHook.podSecurityContext | indent 8 }}
{{- end }}
containers:
- name: delete-pre-1-17-webhook-server-cert
image: '{{ template "system_default_registry" . }}{{ .Values.preDeleteJob.image.repository }}:{{ .Values.preDeleteJob.image.tag }}'
command: ["kubectl", "--namespace", "{{ .Release.Namespace }}", "delete", "--ignore-not-found", "secret", "webhook-server-cert"]
{{- if .Values.preDeleteHook.containerSecurityContext }}
securityContext:
{{ toYaml .Values.preDeleteHook.containerSecurityContext | indent 12 }}
{{- end }}

0 comments on commit aab7910

Please sign in to comment.