|
| 1 | +apiVersion: batch/v1 |
| 2 | +kind: Job |
| 3 | +metadata: |
| 4 | + name: {{ .Chart.Name }}-create |
| 5 | + namespace: {{ .Release.Namespace }} |
| 6 | + labels: |
| 7 | + app: {{ .Chart.Name }} |
| 8 | + annotations: |
| 9 | + "helm.sh/hook": post-install, post-upgrade, post-rollback |
| 10 | + "helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed |
| 11 | +spec: |
| 12 | + template: |
| 13 | + metadata: |
| 14 | + name: {{ .Chart.Name }}-create |
| 15 | + labels: |
| 16 | + app: {{ .Chart.Name }} |
| 17 | + spec: |
| 18 | + serviceAccountName: {{ .Chart.Name }}-manager |
| 19 | + securityContext: |
| 20 | + runAsNonRoot: false |
| 21 | + runAsUser: 0 |
| 22 | + containers: |
| 23 | + - name: create-crds |
| 24 | + image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag }} |
| 25 | + imagePullPolicy: IfNotPresent |
| 26 | + command: |
| 27 | + - /bin/sh |
| 28 | + - -c |
| 29 | + - > |
| 30 | + echo "Applying CRDs..."; |
| 31 | + mkdir -p /etc/crd; |
| 32 | + base64 -d /etc/config/crd-manifest.tgz.b64 | tar -xzv -C /etc/crd; |
| 33 | + kubectl replace -Rf /etc/crd || kubectl create -Rf /etc/crd; |
| 34 | + echo "Done!" |
| 35 | + volumeMounts: |
| 36 | + - name: crd-manifest |
| 37 | + readOnly: true |
| 38 | + mountPath: /etc/config |
| 39 | + restartPolicy: OnFailure |
| 40 | + nodeSelector: {{ include "linux-node-selector" . | nindent 8 }} |
| 41 | + {{- if .Values.nodeSelector }} |
| 42 | + {{- toYaml .Values.nodeSelector | nindent 8 }} |
| 43 | + {{- end }} |
| 44 | + tolerations: {{ include "linux-node-tolerations" . | nindent 8 }} |
| 45 | + {{- if .Values.tolerations }} |
| 46 | + {{- toYaml .Values.tolerations | nindent 8 }} |
| 47 | + {{- end }} |
| 48 | + volumes: |
| 49 | + - name: crd-manifest |
| 50 | + configMap: |
| 51 | + name: {{ .Chart.Name }}-manifest |
| 52 | +--- |
| 53 | +apiVersion: batch/v1 |
| 54 | +kind: Job |
| 55 | +metadata: |
| 56 | + name: {{ .Chart.Name }}-delete |
| 57 | + namespace: {{ .Release.Namespace }} |
| 58 | + labels: |
| 59 | + app: {{ .Chart.Name }} |
| 60 | + annotations: |
| 61 | + "helm.sh/hook": pre-delete |
| 62 | + "helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed |
| 63 | +spec: |
| 64 | + template: |
| 65 | + metadata: |
| 66 | + name: {{ .Chart.Name }}-delete |
| 67 | + labels: |
| 68 | + app: {{ .Chart.Name }} |
| 69 | + spec: |
| 70 | + serviceAccountName: {{ .Chart.Name }}-manager |
| 71 | + securityContext: |
| 72 | + runAsNonRoot: false |
| 73 | + runAsUser: 0 |
| 74 | + containers: |
| 75 | + - name: delete-crds |
| 76 | + image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag }} |
| 77 | + imagePullPolicy: IfNotPresent |
| 78 | + command: |
| 79 | + - /bin/sh |
| 80 | + - -c |
| 81 | + - > |
| 82 | + echo "Deleting CRDs..."; |
| 83 | + mkdir -p /etc/crd; |
| 84 | + base64 -d /etc/config/crd-manifest.tgz.b64 | tar -xzv -C /etc/crd; |
| 85 | + kubectl delete --ignore-not-found=true -Rf /etc/crd; |
| 86 | + volumeMounts: |
| 87 | + - name: crd-manifest |
| 88 | + readOnly: true |
| 89 | + mountPath: /etc/config |
| 90 | + restartPolicy: OnFailure |
| 91 | + nodeSelector: {{ include "linux-node-selector" . | nindent 8 }} |
| 92 | + {{- if .Values.nodeSelector }} |
| 93 | + {{- toYaml .Values.nodeSelector | nindent 8 }} |
| 94 | + {{- end }} |
| 95 | + tolerations: {{ include "linux-node-tolerations" . | nindent 8 }} |
| 96 | + {{- if .Values.tolerations }} |
| 97 | + {{- toYaml .Values.tolerations | nindent 8 }} |
| 98 | + {{- end }} |
| 99 | + volumes: |
| 100 | + - name: crd-manifest |
| 101 | + configMap: |
| 102 | + name: {{ .Chart.Name }}-manifest |
0 commit comments