Skip to content

Use external db replace init db #13

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

Merged
merged 4 commits into from
Jul 4, 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
6 changes: 0 additions & 6 deletions helm-chart/Chart.lock

This file was deleted.

7 changes: 1 addition & 6 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
apiVersion: v2
name: supertokens
description: SuperTokens Core Deployment
dependencies:
- name: postgresql
version: 9.2.1
repository: https://charts.bitnami.com/bitnami
condition: database.postgresql.enabled
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -25,4 +20,4 @@ version: 0.1.1
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "3.13.0"
appVersion: "3.14.0"
2 changes: 1 addition & 1 deletion helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SuperTokens Core Deployment

## Deployment

To install with in cluster postgres deployment, the chart currently does not support external postgres servers.
The chart currently use external postgres servers.


```bash
Expand Down
59 changes: 13 additions & 46 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,7 @@ spec:
{{- if .Values.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- end }}
initContainers:
- name: postgres-init
image: "{{ .Values.database.postgresql.initContainer.image.repository }}:{{ .Values.database.postgresql.initContainer.image.tag | default "latest" }}"
command:
- 'sh'
- '-c'
- "until psql postgresql://postgres:${POSTGRES_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:5432;
do echo trying to connect to postgres - waiting 5 sec for it to load up; sleep 5;done;echo succes connecting to postgres;
psql postgresql://postgres:${POSTGRES_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:5432 -c \"CREATE ROLE ${SUPERTOKENS_USER} WITH LOGIN ENCRYPTED PASSWORD '${SUPERTOKENS_PASSWORD}'\";
psql postgresql://postgres:${POSTGRES_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:5432 -c \"CREATE DATABASE {{ .Values.database.dbName }} WITH OWNER = ${SUPERTOKENS_USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 \";"
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgresql
key: postgresql-password
optional: false
- name: SUPERTOKENS_USER
valueFrom:
secretKeyRef:
name: {{ include "supertokens.fullname" . }}-db-creds
key: dbUsername
optional: false
- name: SUPERTOKENS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "supertokens.fullname" . }}-db-creds
key: dbPassword
optional: false
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- if .Values.securityContext }}
Expand All @@ -70,12 +41,20 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: "POSTGRESQL_CONNECTION_URI"
value: "postgresql://${SUPERTOKENS_USER}:${SUPERTOKENS_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.postgresql.port }}/{{ .Values.database.dbName }}"
- name: "POSTGRESQL_DATABASE_NAME"
value: {{ quote .Values.database.name }}
- name: "POSTGRESQL_PORT"
value: {{ quote .Values.database.port }}
- name: "POSTGRESQL_HOST"
value: {{ quote .Values.database.host }}
- name: "POSTGRESQL_USER"
value: {{ quote .Values.database.user }}
- name: "POSTGRESQL_PASSWORD"
value: {{ quote .Values.database.password }}
- name: "POSTGRESQL_CONNECTION_POOL_SIZE"
value: {{ quote .Values.database.connectionPoolSize }}
- name: "SUPERTOKENS_PORT"
value: {{ quote .Values.service.port }}
- name: "POSTGRESQL_CONNECTION_POOL_SIZE"
value: {{ quote .Values.postgresql.connectionPoolSize }}
- name: "ACCESS_TOKEN_VALIDITY"
value: {{ quote .Values.accessTokenValidity }}
- name: "ACCESS_TOKEN_BLACKLISTING"
Expand Down Expand Up @@ -104,18 +83,6 @@ spec:
- name: "API_KEYS"
value: "{{ join "," .Values.apiKeys.keys }}"
{{- end }}
- name: SUPERTOKENS_USER
valueFrom:
secretKeyRef:
name: {{ include "supertokens.fullname" . }}-db-creds
key: dbUsername
optional: false
- name: SUPERTOKENS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "supertokens.fullname" . }}-db-creds
key: dbPassword
optional: false
ports:
- name: http
containerPort: 3567
Expand Down
10 changes: 0 additions & 10 deletions helm-chart/templates/secret.yaml

This file was deleted.

54 changes: 8 additions & 46 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ image:
repository: supertokens/supertokens-postgresql
pullPolicy: IfNotPresent
# -- Overrides the image tag whose default is the chart appVersion.
tag: "3.13"

auth: # -- database user and password
dbUsername: supertokens
dbPassword: supersecretpassword
tag: "3.14"

replicaCount: 1
imagePullSecrets: []
Expand All @@ -15,49 +11,15 @@ fullnameOverride: ""

database:
# -- database name
dbName: supertokens
postgresql:
enabled: true
initContainer:
image:
repository: postgres
pullPolicy: IfNotPresent
# -- Overrides the image tag whose default is the chart appVersion.
tag: "14.2"
# Specifies the database settings
postgresql:
name: supertokens
# -- database port
port: 5432
# -- database host address
host: postgresql
# -- database username
service:
type: ClusterIP
#nodePort: 30017
connectionPoolSize: 5
persistence:
enabled: true
## A manually managed Persistent Volume and Claim
## If defined, PVC must be created manually before volume will be bound
## The value is evaluated as a template, so, for example, the name can depend on .Release or .Chart
##
# existingClaim:
## The path the volume will be mounted at, useful when using different
## PostgreSQL images.
#mountPath: /bitnami/postgresql
## The subdirectory of the volume to mount to, useful in dev environments
## and one PV for multiple services.
subPath: ""
# storageClass: "-"
accessModes:
- ReadWriteOnce
size: 8Gi
annotations: {}

## updateStrategy for PostgreSQL StatefulSet and its slaves StatefulSets
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies
updateStrategy:
type: RollingUpdate
# -- database host
host: postgres.postgres
# -- database user
user: postgres
# -- database password
password: password

service:
port: 3567
Expand Down