|
45 | 45 | spec: |
46 | 46 | # amount of attempts of labeling a pvc |
47 | 47 | backoffLimit: 3 |
48 | | - # job stops after 60 secounds |
| 48 | + # job stops after 60 seconds |
49 | 49 | activeDeadlineSeconds: 60 |
50 | 50 | template: |
51 | 51 | spec: |
|
77 | 77 | command: ["/scripts/time-stamper.sh"] |
78 | 78 | restartPolicy: OnFailure |
79 | 79 | {{- end }} |
| 80 | + |
| 81 | +{{- if .Values.pvcautodeletion.enabled }} |
| 82 | +apiVersion: v1 |
| 83 | +kind: ServiceAccount |
| 84 | +metadata: |
| 85 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 86 | + namespace: {{ .Release.Namespace }} |
| 87 | +automountServiceAccountToken: true |
| 88 | +--- |
| 89 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 90 | +kind: Role |
| 91 | +metadata: |
| 92 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 93 | + namespace: {{ .Release.Namespace }} |
| 94 | +rules: |
| 95 | +- apiGroups: [""] |
| 96 | + resources: ["pods", "persistentvolumeclaims"] |
| 97 | + verbs: ["get", "list", "patch"] |
| 98 | +--- |
| 99 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 100 | +kind: RoleBinding |
| 101 | +metadata: |
| 102 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 103 | + namespace: {{ .Release.Namespace }} |
| 104 | +subjects: |
| 105 | +- kind: ServiceAccount |
| 106 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 107 | + namespace: {{ .Release.Namespace }} |
| 108 | +roleRef: |
| 109 | + kind: Role |
| 110 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 111 | + apiGroup: rbac.authorization.k8s.io |
| 112 | +--- |
| 113 | +apiVersion: batch/v1 |
| 114 | +kind: CronJob |
| 115 | +metadata: |
| 116 | + name: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 117 | + namespace: {{ .Release.Namespace }} |
| 118 | +spec: |
| 119 | + concurrencyPolicy: Forbid |
| 120 | + successfulJobsHistoryLimit: 3 |
| 121 | + failedJobsHistoryLimit: 1 |
| 122 | + schedule: "@weekly" |
| 123 | + |
| 124 | + jobTemplate: |
| 125 | + spec: |
| 126 | + # amount of attempts of labeling a pvc |
| 127 | + backoffLimit: 3 |
| 128 | + # job stops after 300 seconds |
| 129 | + activeDeadlineSeconds: 300 |
| 130 | + template: |
| 131 | + spec: |
| 132 | + serviceAccountName: {{ include "blueapi.fullname" . }}-pvcautodeletion |
| 133 | + {{- with .Values.tolerations }} |
| 134 | + tolerations: |
| 135 | + {{- toYaml . | nindent 12 }} |
| 136 | + {{- end }} |
| 137 | + |
| 138 | + volumes: |
| 139 | + - name : {{include "blueapi.fullname" . }}-pvc-autodeletion-script |
| 140 | + configMap: |
| 141 | + name: {{include "blueapi.fullname" . }}-pvc-autodeletion-script |
| 142 | + defaultMode: 0555 |
| 143 | + |
| 144 | + |
| 145 | + containers: |
| 146 | + - name: pvcautodeletion |
| 147 | + env: |
| 148 | + - name: RELEASE_NAME |
| 149 | + value: {{ .Release.Name }} |
| 150 | + - name: RELEASE_NAMESPACE |
| 151 | + value: {{ .Release.Namespace }} |
| 152 | + volumeMounts: |
| 153 | + - name: {{include "blueapi.fullname" . }}-pvc-autodeletion-script |
| 154 | + mountPath: /scripts |
| 155 | + image: bitnami/kubectl:latest |
| 156 | + imagePullPolicy: IfNotPresent |
| 157 | + command: ["/scripts/pvc-deletion.sh"] |
| 158 | + restartPolicy: OnFailure |
| 159 | +{{- end }} |
0 commit comments