Skip to content

Commit

Permalink
Merge pull request #18 from selimyanat/run-migration-in-job
Browse files Browse the repository at this point in the history
build(kube-deployment): enable postgres deployment
  • Loading branch information
selimyanat authored Feb 23, 2022
2 parents 60b55fc + 7136f1e commit 1b5b67b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ run-in-docker-compose: build-docker-file
docker-compose down
docker-compose up

build-bitnami-chart:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency build ./infrastructure/coladay-chart

create-kubernetes-namespace:
echo 'Creating Kubernetes namespace if not exists...'
kubectl config use-context docker-desktop
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ make run-in-docker-compose

Navigate to the `cola-day` source directory then:

- Build and import coladay dependency by running the following command:
```
make build-bitnami-chart
```

- Deploy (or upgrade) the application to kubernetes by running the following command:
```
make deploy-to-kubernetes
Expand Down
46 changes: 34 additions & 12 deletions infrastructure/coladay-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,20 @@ spec:
serviceAccountName: {{ include "coladay-chart.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
initContainers:
- name: {{ .Chart.Name }}-init
image: busybox:1.28
command: [ 'sh', '-c', "until nslookup postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for postgresql; sleep 2; done"]
- name: {{ .Chart.Name }}-db-init
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: ENABLE_COLADAY_INIT_MODE
value: "false"
- name: ENABLE_COLADAY_LOCAL_DEV
value: "true"
- name: COLADAY_DB_URL
value: {{ .Values.coladayDbUrl }}
- name: COLADAY_DB_USER
value: {{ .Values.coladayDbUser }}
- name: COLADAY_DB_USER_PASSWORD
value: {{ .Values.coladayDbPassword }}
- name: COLADAY_ROOT_PACKAGE_LOG_LEVEL
value: {{ .Values.coladayLogLevel }}
- name: ENABLE_COLADAY_LOCAL_DEV
value: "false"
- name: DB_ADMIN_URL
value: {{ .Values.dbAdminUrl }}
- name: DB_ADMIN_USER
Expand All @@ -54,6 +49,12 @@ spec:
value: {{ .Values.dbAdminPassword }}
- name: COLADAY_DB_NAME
value: {{ .Values.coladayDbName }}
- name: COLADAY_DB_URL
value: {{ .Values.coladayDbUrl }}
- name: COLADAY_DB_USER
value: {{ .Values.coladayDbUser }}
- name: COLADAY_DB_USER_PASSWORD
value: {{ .Values.coladayDbPassword }}
- name: COLADAY_DB_SCHEMA
value: {{ .Values.coladayDbSchema }}
- name: COLADAY_MIGRATION_DB_URL
Expand All @@ -62,6 +63,27 @@ spec:
value: {{ .Values.coladayMigrationDbUser }}
- name: COLADAY_MIGRATION_DB_USER_PASSWORD
value: {{ .Values.coladayMigrationDbUserPassword }}
- name: COLADAY_ROOT_PACKAGE_LOG_LEVEL
value: {{ .Values.coladayLogLevel }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: ENABLE_COLADAY_INIT_MODE
value: "false"
- name: ENABLE_COLADAY_LOCAL_DEV
value: "false"
- name: COLADAY_DB_URL
value: {{ .Values.coladayDbUrl }}
- name: COLADAY_DB_USER
value: {{ .Values.coladayDbUser }}
- name: COLADAY_DB_USER_PASSWORD
value: {{ .Values.coladayDbPassword }}
- name: COLADAY_ROOT_PACKAGE_LOG_LEVEL
value: {{ .Values.coladayLogLevel }}
ports:
- name: http
containerPort: 8080
Expand Down

0 comments on commit 1b5b67b

Please sign in to comment.