diff --git a/restic/templates/cronjob.yaml b/restic/templates/cronjob_backup.yaml similarity index 97% rename from restic/templates/cronjob.yaml rename to restic/templates/cronjob_backup.yaml index 502d4d6bb19f2d36b880302bc9bb8368c82b8c58..d28be75d5c4cc36aa7112c08b91d76fcfecc020a 100644 --- a/restic/templates/cronjob.yaml +++ b/restic/templates/cronjob_backup.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: CronJob metadata: - name: {{ include "restic-helm.fullname" . }} + name: {{ include "restic-helm.fullname" . }}-backup labels: {{- include "restic-helm.labels" . | nindent 4 }} spec: diff --git a/restic/templates/cronjob_forget.yaml b/restic/templates/cronjob_forget.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cbd2e83e5a923d97dcd3853a8b9c85a666e8c4d5 --- /dev/null +++ b/restic/templates/cronjob_forget.yaml @@ -0,0 +1,62 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "restic-helm.fullname" . }}-forget + labels: + {{- include "restic-helm.labels" . | nindent 4 }} +spec: + schedule: "{{ .Values.schedule }}" + jobTemplate: + metadata: + {{- with .Values.jobAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "restic-helm.labels" . | nindent 8 }} + spec: + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 12 }} + {{- end }} + labels: + {{- include "restic-helm.labels" . | nindent 12 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 16 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + workingDir: "/sync" + args: + - "-r" + - "{{ .Values.repository.name }}" + - "forget" + - "--prune" + {{- toYaml .Values.keepOptions | nindent 16 }} + envFrom: + - secretRef: + name: {{ include "restic-helm.fullname" . }} + resources: + {{- toYaml .Values.resources | nindent 16 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} diff --git a/restic/templates/pre-install-job.yaml b/restic/templates/post-install-job.yaml similarity index 86% rename from restic/templates/pre-install-job.yaml rename to restic/templates/post-install-job.yaml index 9a8d92d713c0a6d499bf8cbabc0a3ad711b47861..347202aa3d178d72270c7d675ab695e2b2b1f55e 100644 --- a/restic/templates/pre-install-job.yaml +++ b/restic/templates/post-install-job.yaml @@ -1,9 +1,9 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ include "restic-helm.fullname" . }} + name: {{ include "restic-helm.fullname" . }}-init annotations: - "helm.sh/hook": pre-install + "helm.sh/hook": post-install "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": hook-succeeded labels: @@ -25,9 +25,6 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} - volumes: - - name: data - {{- .Values.volume | nindent 10 }} containers: - name: {{ .Chart.Name }} securityContext: @@ -44,9 +41,6 @@ spec: name: {{ include "restic-helm.fullname" . }} resources: {{- toYaml .Values.resources | nindent 12 }} - volumeMounts: - - mountPath: "/sync" - name: data {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/restic/values.yaml b/restic/values.yaml index 039b5751b247e1e1b9cb32bfa09c9b298281a5e9..4fbdc68392282aa91922e6ed5d846a63df6ad027 100644 --- a/restic/values.yaml +++ b/restic/values.yaml @@ -12,6 +12,10 @@ volume: |- schedule: "0 0 * * *" +keepOptions: + - "--keep-daily" + - "7" + auth: |- B2_ACCOUNT_ID: "AzureDiamond" B2_ACCOUNT_KEY: "hunter2"