f139f51a by Adam Heath

Split cronjob.yaml into separate files.

1 parent 137d11db
1 apiVersion: v1
2 kind: ConfigMap
3 metadata:
4 name: {{ include "postgresql-rclone.fullname" . }}-backup-local
5 data:
6 POSTGRES_DB: |-
7 {{- range $database := .Values.postgresql.databases }}
8 {{ $database }}
9 {{- end }}{{ .Values.local.postgresDb | quote }}
10 BACKUP_KEEP_DAYS: {{ .Values.local.backupKeepDays | quote }}
11
...@@ -11,43 +11,6 @@ spec: ...@@ -11,43 +11,6 @@ spec:
11 requests: 11 requests:
12 storage: {{ .Values.backup.pvc.size }} 12 storage: {{ .Values.backup.pvc.size }}
13 --- 13 ---
14 apiVersion: v1
15 kind: ConfigMap
16 metadata:
17 name: {{ include "postgresql-rclone.fullname" . }}-backup-local
18 data:
19 POSTGRES_DB: |-
20 {{- range $database := .Values.postgresql.databases }}
21 {{ $database }}
22 {{- end }}{{ .Values.local.postgresDb | quote }}
23 BACKUP_KEEP_DAYS: {{ .Values.local.backupKeepDays | quote }}
24 ---
25 apiVersion: v1
26 kind: Secret
27 metadata:
28 name: {{ include "postgresql-rclone.fullname" . }}-auth
29 stringData:
30 POSTGRES_USER: {{ .Values.postgresql.auth.postgresqlUser }}
31 POSTGRES_PASSWORD: {{ .Values.postgresql.auth.postgresqlPassword }}
32 ---
33 {{- if .Values.rclone.enabled }}
34 apiVersion: v1
35 kind: ConfigMap
36 metadata:
37 name: {{ include "postgresql-rclone.fullname" . }}-rclone
38 data:
39 {{ .Values.rclone.config | toYaml | nindent 2 }}
40 {{- end }}
41 ---
42 {{- if .Values.rclone.enabled }}
43 apiVersion: v1
44 kind: Secret
45 metadata:
46 name: {{ include "postgresql-rclone.fullname" . }}-rclone
47 stringData:
48 {{ .Values.rclone.secret | toYaml | nindent 2 }}
49 {{- end }}
50 ---
51 apiVersion: batch/v1 14 apiVersion: batch/v1
52 kind: CronJob 15 kind: CronJob
53 metadata: 16 metadata:
...@@ -148,107 +111,4 @@ spec: ...@@ -148,107 +111,4 @@ spec:
148 mountPath: /backups 111 mountPath: /backups
149 command: ["ls"] 112 command: ["ls"]
150 args: ["-alR", "/backups"] 113 args: ["-alR", "/backups"]
151 ---
152 apiVersion: v1
153 kind: PersistentVolumeClaim
154 metadata:
155 name: {{ include "postgresql-rclone.fullname" . }}-restores
156 spec:
157 storageClassName: {{ .Values.restore.pvc.storageClassName }}
158 accessModes:
159 - ReadWriteOnce
160 resources:
161 requests:
162 storage: {{ .Values.restore.pvc.size }}
163 ---
164 apiVersion: batch/v1
165 kind: Job
166 metadata:
167 name: {{ include "postgresql-rclone.fullname" . }}-restore
168 labels:
169 {{- include "postgresql-rclone.labels" . | nindent 4 }}
170 spec:
171 template:
172 spec:
173 restartPolicy: OnFailure
174 imagePullSecrets:
175 {{- toYaml .Values.imagePullSecrets | nindent 12 }}
176 volumes:
177 - name: restores
178 persistentVolumeClaim:
179 claimName: {{ include "postgresql-rclone.fullname" . }}-restores
180 {{- if .Values.rclone.enabled }}
181 - name: rclone-auth
182 secret:
183 secretName: {{ include "postgresql-rclone.fullname" . }}-rclone
184 - name: rclone-config
185 configMap:
186 name: {{ include "postgresql-rclone.fullname" . }}-rclone
187 {{- end }}
188 initContainers:
189 {{- if .Values.rclone.enabled }}
190 - name: rclone
191 image: "{{ .Values.rclone.image.repository }}:{{ .Values.rclone.image.tag }}"
192 imagePullPolicy: {{ .Values.rclone.image.pullPolicy }}
193 volumeMounts:
194 - name: restores
195 mountPath: /restores
196 - name: rclone-config
197 mountPath: /config
198 - name: rclone-auth
199 mountPath: /secret
200 envFrom:
201 - configMapRef:
202 name: {{ include "postgresql-rclone.fullname" . }}-rclone
203 - secretRef:
204 name: {{ include "postgresql-rclone.fullname" . }}-rclone
205 {{- if .Values.rclone.crypt.enabled }}
206 env:
207 - name: RCLONE_CRYPT_REMOTE
208 value: ":s3:$(S3_BUCKET)/$(S3_PREFIX)/last/"
209 {{- end }}
210 {{- if .Values.rclone.crypt.enabled }}
211 args: ["copy", ":crypt:", "/restores/"]
212 {{- else }}
213 args: ["-v", "copy", ":s3:$(S3_BUCKET)/$(S3_PREFIX)/last/", "/restores/.work/"]
214 {{- end }}
215 {{- end }}
216 - name: link-latest
217 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
218 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
219 volumeMounts:
220 - name: restores
221 mountPath: /restores
222 command:
223 - bash
224 - -cx
225 - |-
226 find /restores/.work -maxdepth 1 -mindepth 1 -name '*.sql.gz' | \
227 sort | \
228 awk '{split($1, a, /-([^-]*)-([^-]*)$/)} !uniq[a[1] a[2] a[3]]++' | \
229 while read file; do \
230 ln -f "$file" "/restores/"
231 done
232 - name: show-restores
233 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
234 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
235 volumeMounts:
236 - name: restores
237 mountPath: /restores
238 command: ["ls"]
239 args: ["-alR", "/restores"]
240
241 containers:
242 - name: ready
243 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
244 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
245 volumeMounts:
246 - name: restores
247 mountPath: /restores
248 command:
249 - bash
250 - -cx
251 - |-
252 touch /restores/.restored
253
254 114
......
1 ---
2 apiVersion: v1
3 kind: PersistentVolumeClaim
4 metadata:
5 name: {{ include "postgresql-rclone.fullname" . }}-restores
6 spec:
7 storageClassName: {{ .Values.restore.pvc.storageClassName }}
8 accessModes:
9 - ReadWriteOnce
10 resources:
11 requests:
12 storage: {{ .Values.restore.pvc.size }}
13 ---
14 apiVersion: batch/v1
15 kind: Job
16 metadata:
17 name: {{ include "postgresql-rclone.fullname" . }}-restore
18 labels:
19 {{- include "postgresql-rclone.labels" . | nindent 4 }}
20 spec:
21 template:
22 spec:
23 restartPolicy: OnFailure
24 imagePullSecrets:
25 {{- toYaml .Values.imagePullSecrets | nindent 12 }}
26 volumes:
27 - name: restores
28 persistentVolumeClaim:
29 claimName: {{ include "postgresql-rclone.fullname" . }}-restores
30 {{- if .Values.rclone.enabled }}
31 - name: rclone-auth
32 secret:
33 secretName: {{ include "postgresql-rclone.fullname" . }}-rclone
34 - name: rclone-config
35 configMap:
36 name: {{ include "postgresql-rclone.fullname" . }}-rclone
37 {{- end }}
38 initContainers:
39 {{- if .Values.rclone.enabled }}
40 - name: rclone
41 image: "{{ .Values.rclone.image.repository }}:{{ .Values.rclone.image.tag }}"
42 imagePullPolicy: {{ .Values.rclone.image.pullPolicy }}
43 volumeMounts:
44 - name: restores
45 mountPath: /restores
46 - name: rclone-config
47 mountPath: /config
48 - name: rclone-auth
49 mountPath: /secret
50 envFrom:
51 - configMapRef:
52 name: {{ include "postgresql-rclone.fullname" . }}-rclone
53 - secretRef:
54 name: {{ include "postgresql-rclone.fullname" . }}-rclone
55 {{- if .Values.rclone.crypt.enabled }}
56 env:
57 - name: RCLONE_CRYPT_REMOTE
58 value: ":s3:$(S3_BUCKET)/$(S3_PREFIX)/last/"
59 {{- end }}
60 {{- if .Values.rclone.crypt.enabled }}
61 args: ["copy", ":crypt:", "/restores/"]
62 {{- else }}
63 args: ["-v", "copy", ":s3:$(S3_BUCKET)/$(S3_PREFIX)/last/", "/restores/.work/"]
64 {{- end }}
65 {{- end }}
66 - name: link-latest
67 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
68 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
69 volumeMounts:
70 - name: restores
71 mountPath: /restores
72 command:
73 - bash
74 - -cx
75 - |-
76 find /restores/.work -maxdepth 1 -mindepth 1 -name '*.sql.gz' | \
77 sort | \
78 awk '{split($1, a, /-([^-]*)-([^-]*)$/)} !uniq[a[1] a[2] a[3]]++' | \
79 while read file; do \
80 ln -f "$file" "/restores/"
81 done
82 - name: show-restores
83 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
84 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
85 volumeMounts:
86 - name: restores
87 mountPath: /restores
88 command: ["ls"]
89 args: ["-alR", "/restores"]
90
91 containers:
92 - name: ready
93 image: "{{ .Values.bash.image.repository }}:{{ .Values.bash.image.tag }}"
94 imagePullPolicy: {{ .Values.bash.image.pullPolicy }}
95 volumeMounts:
96 - name: restores
97 mountPath: /restores
98 command:
99 - bash
100 - -cx
101 - |-
102 touch /restores/.restored
103
104
1 apiVersion: v1
2 kind: Secret
3 metadata:
4 name: {{ include "postgresql-rclone.fullname" . }}-auth
5 stringData:
6 POSTGRES_USER: {{ .Values.postgresql.auth.postgresqlUser }}
7 POSTGRES_PASSWORD: {{ .Values.postgresql.auth.postgresqlPassword }}
8
1 {{- if .Values.rclone.enabled }}
2 apiVersion: v1
3 kind: ConfigMap
4 metadata:
5 name: {{ include "postgresql-rclone.fullname" . }}-rclone
6 data:
7 {{ .Values.rclone.config | toYaml | nindent 2 }}
8 {{- end }}
9 ---
10 {{- if .Values.rclone.enabled }}
11 apiVersion: v1
12 kind: Secret
13 metadata:
14 name: {{ include "postgresql-rclone.fullname" . }}-rclone
15 stringData:
16 {{ .Values.rclone.secret | toYaml | nindent 2 }}
17 {{- end }}
18