-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(helm): add s3 bucket retention job
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{- if .Values.backup.enabled -}} | ||
{{- if .Values.backup.s3.retention -}} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
labels: | ||
{{- include "etcd.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade,post-rollback | ||
"helm.sh/hook-weight": "5" | ||
"helm.sh/hook-delete-policy": "hook-succeeded,hook-failed" | ||
name: "{{ .Release.Name }}-s3-retention" | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
template: | ||
metadata: | ||
name: "{{ .Release.Name }}" | ||
spec: | ||
serviceAccountName: {{ include "etcd.serviceAccountName" . }} | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: minio-client | ||
image: {{ include "minio-client.fullyQualifiedDockerImage" . }} | ||
imagePullPolicy: {{ .Values.backup.s3.image.pullPolicy }} | ||
command: | ||
- bash | ||
- -c | ||
- |- | ||
cd ${MC_CONFIG_DIR} | ||
if $MC alias set myminio {{ .Values.backup.s3.url }} {{ .Values.backup.s3.accessKey }} {{ .Values.backup.s3.secretKey }} \ | ||
&& $MC ping myminio -c 3 -e 3 ; then | ||
echo -e "\nCheck for already created object lifecycle management rule(s):" | ||
if $MC ilm ls myminio/{{ .Values.backup.s3.bucket }} ; then | ||
echo -e "\nObject lifecycle management rule(s) found - Clean up:" | ||
$MC ilm rm --all --force myminio/{{ .Values.backup.s3.bucket }} | ||
else | ||
echo -e "\nNo object lifecycle management rule(s) found - Continue" | ||
fi | ||
echo -e "\nAdding object lifecycle management rule(s):" | ||
$MC ilm add {{ .Values.backup.s3.retention }} myminio/{{ .Values.backup.s3.bucket }} | ||
$MC ilm ls myminio/{{ .Values.backup.s3.bucket }} | ||
else | ||
echo -e "\nERROR: S3 storage could not be configured;\nCheck your S3 URL/Credentials or network connectivity" | ||
exit 1 | ||
fi | ||
env: | ||
- name: MC_CONFIG_DIR | ||
value: /tmp | ||
- name: MC | ||
value: "/usr/bin/mc --config-dir ${MC_CONFIG_DIR}" | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
fsGroup: 1000 | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters