github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/velero/templates/cleanup-crds.yaml (about)

     1  {{- if .Values.cleanUpCRDs }}
     2  # This job is meant primarily for cleaning up on CI systems.
     3  # Using this on production systems, especially those that have multiple releases of Velero, will be destructive.
     4  {{/* 'securityContext' got renamed to 'podSecurityContext', merge both dicts into one for backward compatibility */}}
     5  {{- $podSecurityContext := merge (.Values.podSecurityContext | default dict) (.Values.securityContext | default dict) -}}
     6  apiVersion: batch/v1
     7  kind: Job
     8  metadata:
     9    name: {{ template "velero.fullname" . }}-cleanup-crds
    10    namespace: {{ .Release.Namespace }}
    11    annotations:
    12      "helm.sh/hook": pre-delete
    13      "helm.sh/hook-delete-policy": hook-succeeded
    14    labels:
    15      app.kubernetes.io/name: {{ include "velero.name" . }}
    16      app.kubernetes.io/instance: {{ .Release.Name }}
    17      app.kubernetes.io/managed-by: {{ .Release.Service }}
    18      helm.sh/chart: {{ include "velero.chart" . }}
    19  spec:
    20    backoffLimit: 3
    21    template:
    22      metadata:
    23        name: velero-cleanup-crds
    24        {{- with .Values.kubectl.labels }}
    25        labels:
    26          {{- toYaml . | nindent 8 }}
    27        {{- end }}
    28        {{- with .Values.kubectl.annotations }}
    29        annotations:
    30          {{- toYaml . | nindent 8 }}
    31        {{- end }}
    32      spec:
    33      {{- if .Values.image.imagePullSecrets }}
    34        imagePullSecrets:
    35        {{- range .Values.image.imagePullSecrets }}
    36          - name: {{ . }}
    37        {{- end }}
    38      {{- end }}
    39        serviceAccountName: {{ include "velero.serverServiceAccount" . }}
    40        containers:
    41          - name: kubectl
    42            {{- if .Values.kubectl.image.digest }}
    43            image: "{{ .Values.kubectl.image.repository }}@{{ .Values.kubectl.image.digest }}"
    44            {{- else if .Values.kubectl.image.tag }}
    45            image: "{{ .Values.kubectl.image.repository }}:{{ .Values.kubectl.image.tag }}"
    46            {{- else }}
    47            image: "{{ .Values.kubectl.image.repository }}:{{ template "chart.KubernetesVersion" . }}"
    48            {{- end }}
    49            imagePullPolicy: {{ .Values.image.pullPolicy }}
    50            command:
    51              - /bin/sh
    52              - -c
    53              - >
    54                kubectl delete restore --all;
    55                kubectl delete backup --all;
    56                kubectl delete backupstoragelocation --all;
    57                kubectl delete volumesnapshotlocation --all;
    58                kubectl delete podvolumerestore --all;
    59                kubectl delete crd -l component=velero;
    60            {{- with .Values.kubectl.containerSecurityContext }}
    61            securityContext:
    62              {{- toYaml . | nindent 12 }}
    63            {{- end }}
    64            {{- with .Values.kubectl.resources }}
    65            resources:
    66              {{- toYaml . | nindent 12 }}
    67            {{- end }}
    68        restartPolicy: OnFailure
    69        {{- with $podSecurityContext }}
    70        securityContext:
    71          {{- toYaml . | nindent 8 }}
    72        {{- end }}
    73        {{- with .Values.nodeSelector }}
    74        nodeSelector:
    75          {{- toYaml . | nindent 8 }}
    76        {{- end }}
    77        {{- with .Values.tolerations }}
    78        tolerations:
    79          {{- toYaml . | nindent 8 }}
    80        {{- end }}
    81        {{- with .Values.affinity }}
    82        affinity:
    83          {{- toYaml . | nindent 8 }}
    84        {{- end }}
    85  {{- end }}