From 4e8456a8904e1858834401d0c031270f2ba9f154 Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Thu, 17 Jun 2021 16:25:33 -0600 Subject: [PATCH] feat(pontoon): support more customization to jobs - initContainers - volumes & volumeMounts - command - args --- charts/pontoon/Chart.lock | 7 +++++-- charts/pontoon/Chart.yaml | 5 ++++- .../templates/pontoon-migration-job.yaml | 17 +++++++++++++++++ .../pontoon-sync-projects-cronjob.yaml | 16 +++++++++++++++- charts/pontoon/values.yaml | 17 +++++++++++++++++ 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/charts/pontoon/Chart.lock b/charts/pontoon/Chart.lock index 11a6c35..bf5c055 100644 --- a/charts/pontoon/Chart.lock +++ b/charts/pontoon/Chart.lock @@ -5,5 +5,8 @@ dependencies: - name: rabbitmq repository: https://charts.bitnami.com/bitnami version: 8.6.0 -digest: sha256:acbca669c00cbf636183b351ee7606b260c0f831b7fe4a4a53064f11f62f6795 -generated: "2020-12-19T15:28:59.246349-07:00" +- name: common + repository: https://charts.bitnami.com/bitnami + version: 1.6.1 +digest: sha256:565db712947d277c4e162a6ee6aa7644056a85ba19b6de25f871c738213c3422 +generated: "2021-06-17T15:50:56.824871-06:00" diff --git a/charts/pontoon/Chart.yaml b/charts/pontoon/Chart.yaml index 5fe1984..9aac0c7 100644 --- a/charts/pontoon/Chart.yaml +++ b/charts/pontoon/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: pontoon home: https://github.com/mozilla/pontoon -version: 1.4.0 +version: 1.5.0 # Pontoon no longer cuts releases. # See https://github.com/mozilla/pontoon/releases/tag/2018-12-19 # and https://hub.docker.com/r/skillsnetwork/pontoon/tags @@ -25,3 +25,6 @@ dependencies: version: 8.6.0 repository: https://charts.bitnami.com/bitnami condition: rabbitmq.enabled + - name: common + version: 1.x.x + repository: https://charts.bitnami.com/bitnami diff --git a/charts/pontoon/templates/pontoon-migration-job.yaml b/charts/pontoon/templates/pontoon-migration-job.yaml index bd5839c..694339e 100644 --- a/charts/pontoon/templates/pontoon-migration-job.yaml +++ b/charts/pontoon/templates/pontoon-migration-job.yaml @@ -35,6 +35,12 @@ spec: {{- end }} serviceAccountName: {{ include "pontoon.serviceAccountName" . }} restartPolicy: Never + {{- if .Values.migrationJob.initContainers }} + initContainers: + {{- if .Values.migrationJob.initContainers }} + {{- include "common.tplvalues.render" (dict "value" .Values.migrationJob.initContainers "context" $) | nindent 8 }} + {{- end }} + {{- end }} containers: - name: pontoon-migration image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" @@ -42,8 +48,13 @@ spec: envFrom: - secretRef: name: "{{ include "pontoon.fullname" . }}-secrets" + {{- if or .Values.migrationJob.command .Values.migrationJob.args }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.migrationJob.command "context" $) | nindent 10 }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.migrationJob.args "context" $) | nindent 10 }} + {{- else }} command: ["python"] args: ["manage.py", "migrate"] + {{- end }} env: - name: SITE_URL value: {{ .Values.siteUrl | quote }} @@ -63,9 +74,15 @@ spec: name: "pontoon-settings" subPath: "custom.py" {{- end }} + {{- if .Values.migrationJob.extraVolumeMounts }} + {{- include "common.tplvalues.render" (dict "value" .Values.migrationJob.extraVolumeMounts "context" $) | nindent 12 }} + {{- end }} volumes: {{- if .Values.extraSettingsModule }} - name: "pontoon-settings" configMap: name: "{{ include "pontoon.fullname" . }}-settings-configmap" {{- end }} + {{- if .Values.migrationJob.extraVolumes }} + {{- include "common.tplvalues.render" (dict "value" .Values.migrationJob.extraVolumes "context" $) | nindent 8 }} + {{- end }} diff --git a/charts/pontoon/templates/pontoon-sync-projects-cronjob.yaml b/charts/pontoon/templates/pontoon-sync-projects-cronjob.yaml index b347f7c..0048848 100644 --- a/charts/pontoon/templates/pontoon-sync-projects-cronjob.yaml +++ b/charts/pontoon/templates/pontoon-sync-projects-cronjob.yaml @@ -47,7 +47,7 @@ spec: securityContext: {{- toYaml .Values.syncProjectCronjob.podSecurityContext | nindent 12 }} restartPolicy: OnFailure - {{- if or .Values.ssh.config .Values.ssh.privateKeys }} + {{- if or (or .Values.ssh.config .Values.ssh.privateKeys) .Values.syncProjectCronjob.initContainers }} initContainers: - name: copy-ssh-secrets image: "busybox" @@ -61,6 +61,9 @@ spec: name: "dummy-volume" - mountPath: "/ssh-data" name: "pontoon-ssh" + {{- if .Values.syncProjectCronjob.initContainers }} + {{- include "common.tplvalues.render" (dict "value" .Values.syncProjectCronjob.initContainers "context" $) | nindent 12 }} + {{- end }} {{- end }} containers: - name: sync-projects @@ -68,10 +71,15 @@ spec: {{- toYaml .Values.syncProjectCronjob.securityContext | nindent 16 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if or .Values.syncProjectCronjob.command .Values.syncProjectCronjob.args}} + command: {{- include "common.tplvalues.render" (dict "value" .Values.syncProjectCronjob.command "context" $) | nindent 14 }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.syncProjectCronjob.args "context" $) | nindent 14 }} + {{- else }} command: ["python"] args: - "manage.py" - "sync_projects" + {{- end }} resources: {{- toYaml .Values.syncProjectCronjob.resources | nindent 16 }} envFrom: @@ -100,6 +108,9 @@ spec: - name: "dummy-volume" mountPath: {{ .Values.ssh.mountPath | quote }} {{- end }} + {{- if .Values.syncProjectCronjob.extraVolumeMounts }} + {{- include "common.tplvalues.render" (dict "value" .Values.syncProjectCronjob.extraVolumeMounts "context" $) | nindent 16 }} + {{- end }} volumes: {{- if .Values.extraSettingsModule }} - name: "pontoon-settings" @@ -114,6 +125,9 @@ spec: - name: "dummy-volume" emptyDir: {} {{- end }} + {{- if .Values.syncProjectCronjob.extraVolumes }} + {{- include "common.tplvalues.render" (dict "value" .Values.syncProjectCronjob.extraVolumes "context" $) | nindent 12 }} + {{- end }} {{- with .Values.syncProjectCronjob.nodeSelector }} nodeSelector: {{- toYaml . | nindent 12 }} diff --git a/charts/pontoon/values.yaml b/charts/pontoon/values.yaml index 22bdc25..cdd9d3d 100644 --- a/charts/pontoon/values.yaml +++ b/charts/pontoon/values.yaml @@ -95,6 +95,23 @@ syncProjectCronjob: affinity: {} podSecurityContext: {} securityContext: {} + extraVolumeMounts: [] + extraVolumes: [] + # Add init containers to pod + initContainers: {} + ## Command and args for running the container + command: [] + args: [] + +# Migration job to perform database migration +migrationJob: + extraVolumeMounts: [] + extraVolumes: [] + # Add init containers to pod + initContainers: { } + ## Command and args for running the container + command: [] + args: [] # Configuration values for the postgres dependency # ref: https://github.com/bitnami/charts/blob/master/bitnami/postgresql/README.md