improwised-charts/charts/erpnext/templates/job-migrate-sites.yaml

103 lines
3.4 KiB
YAML

{{- if .Values.migrateJob.enable }}
apiVersion: batch/v1
kind: Job
metadata:
name: migrate-sites-{{ template "erpnext.fullname" . }}-{{ date "20060102150405" .Release.Now }}
labels:
{{- include "erpnext.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
backoffLimit: 1
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "erpnext.serviceAccountName" $ }}
securityContext:
{{- toYaml $.Values.podSecurityContext | nindent 8 }}
initContainers:
- name: set-maintenance-mode
image: stedolan/jq
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c"]
securityContext:
runAsUser: 1000 # same as erpnext user
runAsGroup: 1000
args:
- cp /data/common_site_config.json /data/temp.json;
jq -r '.maintenance_mode=1 | .pause_scheduler=1' /data/temp.json > /data/common_site_config.json;
volumeMounts:
- name: sites-dir
mountPath: "/data"
- name: populate-assets
image: "{{ .Values.nginxImage.repository }}:{{ .Values.nginxImage.tag }}"
command: ["/bin/bash", "-c"]
args:
- "rsync -a --delete /var/www/html/assets/frappe /assets"
volumeMounts:
- name: assets-cache
mountPath: /assets
containers:
- name: migrate
image: "{{ .Values.pythonImage.repository }}:{{ .Values.pythonImage.tag }}"
args: ["migrate"]
env:
- name: "MAINTENANCE_MODE"
value: "1"
securityContext:
{{- toYaml $.Values.securityContext | nindent 12 }}
imagePullPolicy: {{ .Values.pythonImage.pullPolicy }}
volumeMounts:
- name: sites-dir
mountPath: /home/frappe/frappe-bench/sites
- name: assets-cache
mountPath: /home/frappe/frappe-bench/sites/assets
- name: logs
mountPath: /home/frappe/frappe-bench/logs
restartPolicy: Never
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: assets-cache
emptyDir: {}
- name: sites-dir
{{- if .Values.persistence.worker.enabled }}
persistentVolumeClaim:
{{- if .Values.persistence.worker.existingClaim }}
claimName: {{ .Values.persistence.worker.existingClaim }}
{{- else }}
claimName: {{ template "erpnext.fullname" . }}
{{- end }}
readOnly: false
{{- else }}
emptyDir: {}
{{- end }}
- name: logs
{{- if .Values.persistence.logs.enabled }}
persistentVolumeClaim:
{{- if .Values.persistence.logs.existingClaim }}
claimName: {{ .Values.persistence.logs.existingClaim }}
{{- else }}
claimName: {{ template "erpnext.fullname" . }}-logs
{{- end }}
readOnly: false
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}