Skip to content

Commit

Permalink
feat(deployment): add init containers to pods (#30)
Browse files Browse the repository at this point in the history
* feat(rafiki-auth): enableManualMigrations env

* feat(rafiki-backend): enableManualMigrations env

* feat(rafiki-auth): init containers for database migrations

* feat(rafiki-backend): init containers for database migrations

* bump(rafiki-auth): chart version

* bump(rafiki-backend): chart version

* chore(rafiki-frontend): remove unecessary comments

---------

Co-authored-by: tadejgolobic <[email protected]>
  • Loading branch information
golobitch and tadejgolobic authored Apr 3, 2024
1 parent 4e816bb commit 5b33c09
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 59 deletions.
2 changes: 1 addition & 1 deletion charts/rafiki-auth/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.0
version: 0.4.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
1 change: 1 addition & 0 deletions charts/rafiki-auth/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ data:
NODE_ENV: "{{ .Values.nodeEnv }}"
PORT: "{{ .Values.port.auth }}"
WAIT_SECONDS: "{{ .Values.grant.waitSeconds }}"
ENABLE_MANUAL_MIGRATIONS: "{{ .Values.enableManualMigrations }}"
45 changes: 20 additions & 25 deletions charts/rafiki-auth/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,33 @@ spec:
app.kubernetes.io/name: {{ include "rafiki-auth.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets -}}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ if .Values.serviceAccount.create }}
{{- end -}}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ template "auth.serviceAccountName" . }}
{{ with .Values.podSecurityContext -}}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{ end }}
{{- toYaml . | nindent 8 -}}
{{- end -}}
{{- end }}
{{- if .Values.serviceAccount.create -}}
volumes:
{{ if .Values.serviceAccount.create }}
- name: {{ include "rafiki-auth.fullname" . }}-sa-key
secret:
secretName: {{ include "rafiki-auth.fullname" . }}-sa-key
{{ end }}
{{- end }}
{{- if .Values.enableManualMigrations }}
initContainers:
- name: database-migrations
image: {{ include "auth.image" . }}
command: ["npm", "run", "knex -- migrate:latest --env production"]
workingDir: /home/rafiki/packages/auth/
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ include "auth.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand All @@ -57,21 +66,7 @@ spec:
- name: introspection
containerPort: {{ .Values.port.introspection }}
protocol: TCP
#livenessProbe:
# failureThreshold: 15
# initialDelaySeconds: 30
# periodSeconds: 10
# timeoutSeconds: 10
# httpGet:
# path: /healthz
# port: admin
#readinessProbe:
# failureThreshold: 3
# initialDelaySeconds: 5
# periodSeconds: 5
# timeoutSeconds: 5
# httpGet:
# path: /healthz
# port: http
{{- with .Values.resources -}}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end -}}
1 change: 1 addition & 0 deletions charts/rafiki-auth/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
nodeEnv: development
logLevel: debug
enableManualMigrations: true
postgresql:
host: "postgres.example.com"
port: 5432
Expand Down
2 changes: 1 addition & 1 deletion charts/rafiki-backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.0
version: 0.4.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
3 changes: 2 additions & 1 deletion charts/rafiki-backend/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ data:
WEBHOOK_URL: "{{ .Values.serviceUrls.WEBHOOK_URL }}"
WEBHOOK_WORKERS: "{{ .Values.workers.webhook }}"
WEBHOOK_WORKER_IDLE: "{{ .Values.workerIdle }}"
WITHDRAWAL_THROTTLE_DELAY: "{{ .Values.withdrawalThrottleDelay }}"
WITHDRAWAL_THROTTLE_DELAY: "{{ .Values.withdrawalThrottleDelay }}"
ENABLE_MANUAL_MIGRATIONS: "{{ .Values.enableManualMigrations }}"
39 changes: 16 additions & 23 deletions charts/rafiki-backend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,30 @@ spec:
app.kubernetes.io/name: {{ include "rafiki-backend.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets -}}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ if .Values.serviceAccount.create }}
{{- end -}}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ template "backend.serviceAccountName" . }}
{{ with .Values.podSecurityContext -}}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{ end }}
{{- toYaml . | nindent 8 -}}
{{- end -}}
{{- end }}
{{- if .Values.serviceAccount.create -}}
volumes:
{{ if .Values.serviceAccount.create }}
- name: {{ include "rafiki-backend.fullname" . }}-sa-key
secret:
secretName: {{ include "rafiki-backend.fullname" . }}-sa-key
{{ end }}
{{- end }}
{{- if .Values.enableManualMigrations }}
initContainers:
- name: database-migrations
image: {{ include "backend.image" . }}
command: ["npm", "run", "knex -- migrate:latest --env production"]
workingDir: /home/rafiki/packages/backend/
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand All @@ -57,21 +66,5 @@ spec:
- name: connector
containerPort: {{ .Values.port.connector }}
protocol: TCP
#livenessProbe:
# failureThreshold: 15
# initialDelaySeconds: 30
# periodSeconds: 10
# timeoutSeconds: 10
# httpGet:
# path: /healthz
# port: admin
#readinessProbe:
# failureThreshold: 3
# initialDelaySeconds: 5
# periodSeconds: 5
# timeoutSeconds: 5
# httpGet:
# path: /healthz
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
1 change: 1 addition & 0 deletions charts/rafiki-backend/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
nodeEnv: development
logLevel: debug
enableManualMigrations: true
serviceUrls:
PUBLIC_HOST: http://rafiki-backend
OPEN_PAYMENTS_URL: http://rafiki-backend
Expand Down
2 changes: 1 addition & 1 deletion charts/rafiki-frontend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.0
version: 0.4.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
7 changes: 0 additions & 7 deletions charts/rafiki-frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@ serviceAccount:
name: ''
securityContext:
{}
# resources:
# limits:
# memory: 1Gi
# cpu: 450m
# requests:
# memory: 800Mi
# cpu: 300m

0 comments on commit 5b33c09

Please sign in to comment.