Skip to content

Commit

Permalink
feat(helm): move migration script to dedicated initcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanGalloway committed Jun 27, 2024
1 parent 642d293 commit 0163fa7
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion helm-chart/sefaria-project/templates/rollout/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,70 @@ spec:
topologyKey: kubernetes.io/hostname
nodeAffinity:
{{- include "sefaria.nodeAffinities" . | nindent 10 }}
initContainers:
- name: migration
image: "{{ .Values.web.containerImage.imageRegistry }}:{{ .Values.web.containerImage.tag }}"
imagePullPolicy: Always
args: [ "python manage.py migrate" ]
env:
- name: ENV_NAME
value: "{{ .Values.deployEnv }}"
- name: STACK_COMPONENT
value: web
- name: REDIS_HOST
value: "redis-{{ .Values.deployEnv }}"
- name: NODEJS_HOST
value: "node-{{ .Values.deployEnv }}-{{ .Release.Revision }}"
- name: VARNISH_HOST
value: "varnish-{{ .Values.deployEnv }}-{{ .Release.Revision }}"
- name: HELM_REVISION
value: "{{ .Release.Revision }}"
envFrom:
- secretRef:
name: {{ template "sefaria.secrets.elasticUser" . }}
- secretRef:
name: {{ .Values.secrets.localSettings.ref }}
optional: true
- configMapRef:
name: local-settings-{{ .Values.deployEnv }}
- secretRef:
name: local-settings-secrets-{{ .Values.deployEnv }}
optional: true
- configMapRef:
name: local-settings-web-{{ .Values.deployEnv }}
optional: true
- secretRef:
name: local-settings-web-secrets-{{ .Values.deployEnv }}
optional: true
ports:
- containerPort: 80
protocol: TCP
resources: {{ toYaml .Values.web.resources.web.resources | nindent 10 }}
volumeMounts:
# https://stackoverflow.com/questions/53491603/kubernetes-volumemounts-a-file-not-a-directory
- mountPath: /app/sefaria/local_settings.py
name: local-settings
subPath: local_settings.py
readOnly: true
- mountPath: /client-secret
name: client-secret
readOnly: true
#TODO: what is this used for? Is it needed? There's no env var pointing to this location
- mountPath: /google-cloud-secret
name: backup-manager-secret
readOnly: true
- mountPath: /app/logging-secret.json
name: logging-secret
subPath: logging-secret.json
readOnly: true
- name: elastic-cert
mountPath: /etc/ssl/certs/elastic
readOnly: true
containers:
- name: web
image: "{{ .Values.web.containerImage.imageRegistry }}:{{ .Values.web.containerImage.tag }}"
imagePullPolicy: Always
args: [ "python manage.py migrate && gunicorn sefaria.wsgi --access-logfile - --error-logfile - --timeout 300 --threads {{ .Values.web.resources.web.gunicornThreadCount }} --worker-tmp-dir /dev/shm -b 0.0.0.0:80" ]
args: [ "gunicorn sefaria.wsgi --access-logfile - --error-logfile - --timeout 300 --threads {{ .Values.web.resources.web.gunicornThreadCount }} --worker-tmp-dir /dev/shm -b 0.0.0.0:80" ]
env:
# WEB_CONCURRENCY is used for determining the number of server workers
- name: WEB_CONCURRENCY
Expand Down

0 comments on commit 0163fa7

Please sign in to comment.