You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. {{- if .Values.cronjob }}
  2. {{- if .Values.cronjob.enabled }}
  3. apiVersion: batch/v1beta1
  4. kind: CronJob
  5. metadata:
  6. name: {{ include "seaweedfs.fullname" . }}-cronjob
  7. spec:
  8. schedule: "{{ .Values.cronjob.schedule }}"
  9. startingDeadlineSeconds: 200
  10. concurrencyPolicy: Forbid
  11. failedJobsHistoryLimit: 2
  12. successfulJobsHistoryLimit: 2
  13. jobTemplate:
  14. spec:
  15. backoffLimit: 2
  16. template:
  17. spec:
  18. {{- if .Values.cronjob.nodeSelector }}
  19. nodeSelector:
  20. {{ tpl .Values.cronjob.nodeSelector . | indent 12 | trim }}
  21. {{- end }}
  22. {{- if .Values.cronjob.tolerations }}
  23. tolerations:
  24. {{ tpl .Values.cronjob.tolerations . | nindent 12 | trim }}
  25. {{- end }}
  26. restartPolicy: OnFailure
  27. containers:
  28. - name: shell
  29. image: {{ template "cronjob.image" . }}
  30. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  31. resources:
  32. {{- toYaml .Values.cronjob.resources| nindent 16 }}
  33. command:
  34. - sh
  35. - -c
  36. - |
  37. set -ex
  38. echo -e "lock\n\
  39. volume.balance -force \
  40. {{ if .Values.volume.dataCenter }} -dataCenter {{ .Values.volume.dataCenter }}{{ end }}\
  41. {{ if .Values.cronjob.collection }} -collection {{ .Values.cronjob.collection }}{{ end }}\n\
  42. {{- if .Values.cronjob.enableFixReplication }}
  43. volume.fix.replication -collectionPattern={{ .Values.cronjob.collectionPattern }} \n\
  44. {{- end }}
  45. unlock\n" | \
  46. /usr/bin/weed shell \
  47. {{- if .Values.cronjob.master }}
  48. -master {{ .Values.cronjob.master }} \
  49. {{- else }}
  50. -master {{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}.svc:{{ .Values.master.port }} \
  51. {{- end }}
  52. {{- if .Values.cronjob.filer }}
  53. -filer {{ .Values.cronjob.filer }}
  54. {{- else }}
  55. -filer {{ template "seaweedfs.name" . }}-filer.{{ .Release.Namespace }}.svc:{{ .Values.filer.port }}
  56. {{- end }}
  57. {{- end }}
  58. {{- end }}