Skip to content

Commit 49187b9

Browse files
authored
Use external db replace init db (#13)
* feat: use external db * fix: fix connectionPool * fix: fix port int error * fix: remove chart.lock
1 parent 63d7b1f commit 49187b9

File tree

6 files changed

+23
-115
lines changed

6 files changed

+23
-115
lines changed

helm-chart/Chart.lock

Lines changed: 0 additions & 6 deletions
This file was deleted.

helm-chart/Chart.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
apiVersion: v2
22
name: supertokens
33
description: SuperTokens Core Deployment
4-
dependencies:
5-
- name: postgresql
6-
version: 9.2.1
7-
repository: https://charts.bitnami.com/bitnami
8-
condition: database.postgresql.enabled
94
# A chart can be either an 'application' or a 'library' chart.
105
#
116
# Application charts are a collection of templates that can be packaged into versioned archives
@@ -25,4 +20,4 @@ version: 0.1.1
2520
# incremented each time you make changes to the application. Versions are not expected to
2621
# follow Semantic Versioning. They should reflect the version the application is using.
2722
# It is recommended to use it with quotes.
28-
appVersion: "3.13.0"
23+
appVersion: "3.14.0"

helm-chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SuperTokens Core Deployment
66

77
## Deployment
88

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

1111

1212
```bash

helm-chart/templates/deployment.yaml

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,7 @@ spec:
2828
{{- if .Values.podSecurityContext }}
2929
securityContext:
3030
{{- toYaml .Values.podSecurityContext | nindent 8 }}
31-
{{- end }}
32-
initContainers:
33-
- name: postgres-init
34-
image: "{{ .Values.database.postgresql.initContainer.image.repository }}:{{ .Values.database.postgresql.initContainer.image.tag | default "latest" }}"
35-
command:
36-
- 'sh'
37-
- '-c'
38-
- "until psql postgresql://postgres:${POSTGRES_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:5432;
39-
do echo trying to connect to postgres - waiting 5 sec for it to load up; sleep 5;done;echo succes connecting to postgres;
40-
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}'\";
41-
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 \";"
42-
env:
43-
- name: POSTGRES_PASSWORD
44-
valueFrom:
45-
secretKeyRef:
46-
name: {{ .Release.Name }}-postgresql
47-
key: postgresql-password
48-
optional: false
49-
- name: SUPERTOKENS_USER
50-
valueFrom:
51-
secretKeyRef:
52-
name: {{ include "supertokens.fullname" . }}-db-creds
53-
key: dbUsername
54-
optional: false
55-
- name: SUPERTOKENS_PASSWORD
56-
valueFrom:
57-
secretKeyRef:
58-
name: {{ include "supertokens.fullname" . }}-db-creds
59-
key: dbPassword
60-
optional: false
31+
{{- end }}
6132
containers:
6233
- name: {{ .Chart.Name }}
6334
{{- if .Values.securityContext }}
@@ -70,12 +41,20 @@ spec:
7041
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
7142
imagePullPolicy: {{ .Values.image.pullPolicy }}
7243
env:
73-
- name: "POSTGRESQL_CONNECTION_URI"
74-
value: "postgresql://${SUPERTOKENS_USER}:${SUPERTOKENS_PASSWORD}@{{ .Release.Namespace }}-{{ .Values.postgresql.host }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.postgresql.port }}/{{ .Values.database.dbName }}"
44+
- name: "POSTGRESQL_DATABASE_NAME"
45+
value: {{ quote .Values.database.name }}
46+
- name: "POSTGRESQL_PORT"
47+
value: {{ quote .Values.database.port }}
48+
- name: "POSTGRESQL_HOST"
49+
value: {{ quote .Values.database.host }}
50+
- name: "POSTGRESQL_USER"
51+
value: {{ quote .Values.database.user }}
52+
- name: "POSTGRESQL_PASSWORD"
53+
value: {{ quote .Values.database.password }}
54+
- name: "POSTGRESQL_CONNECTION_POOL_SIZE"
55+
value: {{ quote .Values.database.connectionPoolSize }}
7556
- name: "SUPERTOKENS_PORT"
7657
value: {{ quote .Values.service.port }}
77-
- name: "POSTGRESQL_CONNECTION_POOL_SIZE"
78-
value: {{ quote .Values.postgresql.connectionPoolSize }}
7958
- name: "ACCESS_TOKEN_VALIDITY"
8059
value: {{ quote .Values.accessTokenValidity }}
8160
- name: "ACCESS_TOKEN_BLACKLISTING"
@@ -104,18 +83,6 @@ spec:
10483
- name: "API_KEYS"
10584
value: "{{ join "," .Values.apiKeys.keys }}"
10685
{{- end }}
107-
- name: SUPERTOKENS_USER
108-
valueFrom:
109-
secretKeyRef:
110-
name: {{ include "supertokens.fullname" . }}-db-creds
111-
key: dbUsername
112-
optional: false
113-
- name: SUPERTOKENS_PASSWORD
114-
valueFrom:
115-
secretKeyRef:
116-
name: {{ include "supertokens.fullname" . }}-db-creds
117-
key: dbPassword
118-
optional: false
11986
ports:
12087
- name: http
12188
containerPort: 3567

helm-chart/templates/secret.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

helm-chart/values.yaml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ image:
22
repository: supertokens/supertokens-postgresql
33
pullPolicy: IfNotPresent
44
# -- Overrides the image tag whose default is the chart appVersion.
5-
tag: "3.13"
6-
7-
auth: # -- database user and password
8-
dbUsername: supertokens
9-
dbPassword: supersecretpassword
5+
tag: "3.14"
106

117
replicaCount: 1
128
imagePullSecrets: []
@@ -15,49 +11,15 @@ fullnameOverride: ""
1511

1612
database:
1713
# -- database name
18-
dbName: supertokens
19-
postgresql:
20-
enabled: true
21-
initContainer:
22-
image:
23-
repository: postgres
24-
pullPolicy: IfNotPresent
25-
# -- Overrides the image tag whose default is the chart appVersion.
26-
tag: "14.2"
27-
# Specifies the database settings
28-
postgresql:
14+
name: supertokens
2915
# -- database port
3016
port: 5432
31-
# -- database host address
32-
host: postgresql
33-
# -- database username
34-
service:
35-
type: ClusterIP
36-
#nodePort: 30017
37-
connectionPoolSize: 5
38-
persistence:
39-
enabled: true
40-
## A manually managed Persistent Volume and Claim
41-
## If defined, PVC must be created manually before volume will be bound
42-
## The value is evaluated as a template, so, for example, the name can depend on .Release or .Chart
43-
##
44-
# existingClaim:
45-
## The path the volume will be mounted at, useful when using different
46-
## PostgreSQL images.
47-
#mountPath: /bitnami/postgresql
48-
## The subdirectory of the volume to mount to, useful in dev environments
49-
## and one PV for multiple services.
50-
subPath: ""
51-
# storageClass: "-"
52-
accessModes:
53-
- ReadWriteOnce
54-
size: 8Gi
55-
annotations: {}
56-
57-
## updateStrategy for PostgreSQL StatefulSet and its slaves StatefulSets
58-
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies
59-
updateStrategy:
60-
type: RollingUpdate
17+
# -- database host
18+
host: postgres.postgres
19+
# -- database user
20+
user: postgres
21+
# -- database password
22+
password: password
6123

6224
service:
6325
port: 3567

0 commit comments

Comments
 (0)