2020-10-25 15:10:23 +00:00
|
|
|
{{- if .Values.cronjob }}
|
|
|
|
{{- if .Values.cronjob.enabled }}
|
|
|
|
apiVersion: batch/v1beta1
|
|
|
|
kind: CronJob
|
|
|
|
metadata:
|
|
|
|
name: {{ include "seaweedfs.fullname" . }}-cronjob
|
|
|
|
spec:
|
|
|
|
schedule: "{{ .Values.cronjob.schedule }}"
|
2021-01-13 20:13:07 +00:00
|
|
|
startingDeadlineSeconds: 200
|
2020-10-25 15:10:23 +00:00
|
|
|
concurrencyPolicy: Forbid
|
|
|
|
failedJobsHistoryLimit: 2
|
|
|
|
successfulJobsHistoryLimit: 2
|
|
|
|
jobTemplate:
|
|
|
|
spec:
|
|
|
|
backoffLimit: 2
|
|
|
|
template:
|
|
|
|
spec:
|
2021-02-09 07:46:21 +00:00
|
|
|
{{- if .Values.cronjob.nodeSelector }}
|
2020-10-25 15:10:23 +00:00
|
|
|
nodeSelector:
|
2021-02-09 07:46:21 +00:00
|
|
|
{{ tpl .Values.cronjob.nodeSelector . | indent 12 | trim }}
|
2020-10-25 15:10:23 +00:00
|
|
|
{{- end }}
|
2021-02-09 07:46:21 +00:00
|
|
|
{{- if .Values.cronjob.tolerations }}
|
2020-10-25 15:10:23 +00:00
|
|
|
tolerations:
|
2021-02-09 07:46:21 +00:00
|
|
|
{{ tpl .Values.cronjob.tolerations . | nindent 12 | trim }}
|
2020-10-25 15:10:23 +00:00
|
|
|
{{- end }}
|
|
|
|
restartPolicy: OnFailure
|
|
|
|
containers:
|
|
|
|
- name: shell
|
|
|
|
image: {{ template "cronjob.image" . }}
|
|
|
|
imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
|
|
|
|
resources:
|
|
|
|
{{- toYaml .Values.cronjob.resources| nindent 16 }}
|
|
|
|
command:
|
|
|
|
- sh
|
|
|
|
- -c
|
|
|
|
- |
|
|
|
|
set -ex
|
2020-10-25 15:34:55 +00:00
|
|
|
echo -e "lock\n\
|
2021-02-09 07:46:21 +00:00
|
|
|
volume.balance -force \
|
2020-10-25 15:34:55 +00:00
|
|
|
{{ if .Values.volume.dataCenter }} -dataCenter {{ .Values.volume.dataCenter }}{{ end }}\
|
|
|
|
{{ if .Values.cronjob.collection }} -collection {{ .Values.cronjob.collection }}{{ end }}\n\
|
2021-02-09 07:46:21 +00:00
|
|
|
{{- if .Values.cronjob.enableFixReplication }}
|
2021-02-24 07:54:42 +00:00
|
|
|
volume.fix.replication -collectionPattern={{ .Values.cronjob.collectionPattern }} \n\
|
2021-02-09 07:46:21 +00:00
|
|
|
{{- end }}
|
|
|
|
unlock\n" | \
|
2020-10-25 15:10:23 +00:00
|
|
|
/usr/bin/weed shell \
|
|
|
|
{{- if .Values.cronjob.master }}
|
|
|
|
-master {{ .Values.cronjob.master }} \
|
|
|
|
{{- else }}
|
|
|
|
-master {{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}.svc:{{ .Values.master.port }} \
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.cronjob.filer }}
|
|
|
|
-filer {{ .Values.cronjob.filer }}
|
|
|
|
{{- else }}
|
|
|
|
-filer {{ template "seaweedfs.name" . }}-filer.{{ .Release.Namespace }}.svc:{{ .Values.filer.port }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2021-01-13 20:13:07 +00:00
|
|
|
{{- end }}
|