From 5a207494a5f4af316ed772ce102841113c17e1de Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Tue, 17 May 2022 10:44:42 -0300 Subject: [PATCH] Implemented moodle cronjob --- .../v0.1.0/templates/moodle-cronjob.yaml | 80 +++++++++++++++++++ charts/saberes/v0.1.0/values.yaml | 9 +++ 2 files changed, 89 insertions(+) create mode 100644 charts/saberes/v0.1.0/templates/moodle-cronjob.yaml diff --git a/charts/saberes/v0.1.0/templates/moodle-cronjob.yaml b/charts/saberes/v0.1.0/templates/moodle-cronjob.yaml new file mode 100644 index 0000000..4cdc46a --- /dev/null +++ b/charts/saberes/v0.1.0/templates/moodle-cronjob.yaml @@ -0,0 +1,80 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ include "saberes.fullname" . }}-moodlecron + labels: + {{- include "saberes.labels" . | nindent 4 }} +spec: + schedule: {{ .Values.moodle.cron.schedule | quote }} + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + metadata: + labels: + {{- include "saberes.labels" . | nindent 12 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + containers: + - name: {{ .Release.Name }}-moodlecron + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - "/bin/bash" + - "-c" + args: + - "/usr/bin/php /var/www/html/admin/cli/cron.php" + env: + - name: MOODLE_DB_HOST + value: {{ .Values.moodle.dbHost | quote }} + - name: MOODLE_DB_NAME + value: {{ .Values.moodle.dbName | quote }} + - name: MOODLE_DB_PASS + value: {{ .Values.moodle.dbPass | quote }} + - name: MOODLE_DB_USER + value: {{ .Values.moodle.dbUser | quote }} + - name: MOODLE_REVERSEPROXY + value: {{ .Values.moodle.reverseProxy | quote }} + - name: MOODLE_SSLPROXY + value: {{ .Values.moodle.sslProxy | quote }} + - name: MOODLE_URL + {{- if .Values.ingress.tls.enabled }} + value: https://{{ .Values.ingress.hostname }} + {{- else -}} + value: http://{{ .Values.ingress.hostname }} + {{- end }} + - name: OSTICKET_API_KEY + value: {{ .Values.osticket.apiKey | quote }} + - name: OSTICKET_API_URL + value: {{ .Values.osticket.url | quote }} + volumeMounts: + - mountPath: /var/moodledata + name: moodledata + resources: + {{- toYaml .Values.moodle.cron.resources | nindent 16 }} + restartPolicy: OnFailure + volumes: + - name: moodledata + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "saberes.fullname" . }}-moodledata + {{- else }} + emptyDir: {} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} \ No newline at end of file diff --git a/charts/saberes/v0.1.0/values.yaml b/charts/saberes/v0.1.0/values.yaml index f54f875..b378dc3 100644 --- a/charts/saberes/v0.1.0/values.yaml +++ b/charts/saberes/v0.1.0/values.yaml @@ -36,6 +36,15 @@ moodle: dbPass: apass reverseProxy: 'false' sslProxy: 'true' + cron: + schedule: "*/5 1 * * *" # Every 5 mins + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 500m + memory: 400Mi ingress: enabled: true