aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <lebedev_k@tochka.com>2020-10-25 20:10:23 +0500
committerKonstantin Lebedev <lebedev_k@tochka.com>2020-10-25 20:10:23 +0500
commitc2fb1d24901b6a014a0e251b3f6e28c93fae59f8 (patch)
tree3f96342ae04f8e249017fcdc9d092718f270730e
parent46cb692d834682fd3baedc3ec36b0117faad45cb (diff)
downloadseaweedfs-c2fb1d24901b6a014a0e251b3f6e28c93fae59f8.tar.xz
seaweedfs-c2fb1d24901b6a014a0e251b3f6e28c93fae59f8.zip
add k8s cronjob
-rw-r--r--k8s/seaweedfs/templates/_helpers.tpl14
-rw-r--r--k8s/seaweedfs/templates/cronjob.yaml51
-rw-r--r--k8s/seaweedfs/values.yaml10
3 files changed, 75 insertions, 0 deletions
diff --git a/k8s/seaweedfs/templates/_helpers.tpl b/k8s/seaweedfs/templates/_helpers.tpl
index 04a782f8b..44d480e66 100644
--- a/k8s/seaweedfs/templates/_helpers.tpl
+++ b/k8s/seaweedfs/templates/_helpers.tpl
@@ -111,4 +111,18 @@ Inject extra environment vars in the format key:value, if populated
{{- $tag := .Values.global.imageTag | toString -}}
{{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
{{- end -}}
+{{- end -}}
+
+{{/* Return the proper cronjob image */}}
+{{- define "cronjob.image" -}}
+{{- if .Values.cronjob.imageOverride -}}
+{{- $imageOverride := .Values.cronjob.imageOverride -}}
+{{- printf "%s" $imageOverride -}}
+{{- else -}}
+{{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
+{{- $repositoryName := .Values.image.repository | toString -}}
+{{- $name := .Values.global.imageName | toString -}}
+{{- $tag := .Values.global.imageTag | toString -}}
+{{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
+{{- end -}}
{{- end -}} \ No newline at end of file
diff --git a/k8s/seaweedfs/templates/cronjob.yaml b/k8s/seaweedfs/templates/cronjob.yaml
new file mode 100644
index 000000000..6abc6003a
--- /dev/null
+++ b/k8s/seaweedfs/templates/cronjob.yaml
@@ -0,0 +1,51 @@
+{{- if .Values.cronjob }}
+{{- if .Values.cronjob.enabled }}
+apiVersion: batch/v1beta1
+kind: CronJob
+metadata:
+ name: {{ include "seaweedfs.fullname" . }}-cronjob
+spec:
+ schedule: "{{ .Values.cronjob.schedule }}"
+ concurrencyPolicy: Forbid
+ failedJobsHistoryLimit: 2
+ successfulJobsHistoryLimit: 2
+ startingDeadlineSeconds: 300
+ jobTemplate:
+ spec:
+ backoffLimit: 2
+ template:
+ spec:
+ {{- with .Values.cronjob.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 12 }}
+ {{- end }}
+ {{- with .Values.cronjob.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 12 }}
+ {{- 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
+ echo -e "lock\nvolume.balance -force -dataCenter {{ .Values.dataCenter }}\nvolume.fix.replication\nunlock\n" | \
+ /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 }}
+{{- end }} \ No newline at end of file
diff --git a/k8s/seaweedfs/values.yaml b/k8s/seaweedfs/values.yaml
index 35ce49f2e..aefa75501 100644
--- a/k8s/seaweedfs/values.yaml
+++ b/k8s/seaweedfs/values.yaml
@@ -347,6 +347,16 @@ s3:
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
priorityClassName: ""
+cronjob:
+ enabled: false
+ schedule: "*/7 * * * *"
+ resources: nul
+ master: ""
+ filer: ""
+ tolerations: ""
+ nodeSelector: |
+ sw-backend: "true"
+
certificates:
commonName: "SeaweedFS CA"
ipAddresses: []