Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(kube-deployment): enable postgres deployment #18

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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