supertokens

by upstreamyard

Helm chartv0.1.7App 12.5.1Apache-2.0Verified publisher

SuperTokens core, the open-source authentication server (sessions, email/password, passwordless, social login, MFA), with PostgreSQL. Community chart by upstreamyard, not an official SuperTokens chart.

About this chart

SuperTokens Helm chart

Have any questions, feedback or need help (e.g. setup, hardened images, etc.)? Reach out to [email protected]

Helm chart for the SuperTokens core, the open-source authentication server behind SuperTokens' backend SDKs: sessions, email/password, passwordless, social and enterprise login, MFA, roles and multi-tenancy. It uses SuperTokens' official image supertokens/supertokens-postgresql.

Community chart by upstreamyard, not an official SuperTokens chart. SuperTokens is © SuperTokens Inc., licensed under Apache-2.0; its paid features (account linking, multi-tenancy, MFA, dashboard logins, OAuth provider, SAML, security features) need a SuperTokens licence key and fall under the licence in its ee/ folder.

Install

helm repo add upstreamyard https://upstreamyard.github.io/helm-charts
helm install supertokens upstreamyard/supertokens \
  --set supertokens.apiKeys=$(openssl rand -hex 32) \
  --set database.uri='postgresql://user:password@your-postgres:5432/supertokens'

Or from the OCI registry:

helm install supertokens oci://ghcr.io/upstreamyard/charts/supertokens --set supertokens.apiKeys=... --set database.uri=...

Then point your backend SDK at the core, with the same API key:

supertokens.init({
  supertokens: {
    connectionURI: "http://supertokens.<namespace>.svc.cluster.local:3567",
    apiKey: "<your API key>",
  },
  // ...
});

Verifying the chart

Chart packages are PGP-signed. Import the public key (fingerprint 9B416F989B7E6C65F7F3BFAE7689688B20EC7813) and install with --verify:

curl -s https://upstreamyard.github.io/helm-charts/pgp_keys.asc | gpg --dearmor > upstreamyard.gpg
helm install supertokens upstreamyard/supertokens --verify --keyring upstreamyard.gpg --set ...

The OCI copy on GHCR is signed with cosign instead (see the repository README).

Requirements

  • PostgreSQL (required). SuperTokens' notes for 12.2 assume PostgreSQL 14 or newer; this chart is tested with PostgreSQL 18. This chart does not deploy a database.
  • Your backend, running one of SuperTokens' backend SDKs, must reach the Service. Browsers and apps talk to your backend, not to the core.

What the chart does

  • Configuration: the core reads every option of its config.yaml from an environment variable with the upper-case name (ACCESS_TOKEN_VALIDITY, PASSWORD_HASHING_ALG, …). The chart sets the API keys, the database URI, the table schema, log level, telemetry and the schema check; add others with extraEnv. Logs go to stdout (kubectl logs), not to files in the container. At SuperTokens' default level INFO every request is logged, including the probes' (two lines every 5 seconds per pod); supertokens.logLevel: WARN keeps only warnings and errors.
  • API key required: the chart refuses to install without supertokens.apiKeys or supertokens.existingSecret. Without a key, anyone who can reach the core can create, read and delete users. Changing supertokens.apiKeys restarts the pods. To rotate a key without failed requests, add the new key next to the old one (old,new), switch your backend to the new key, then remove the old one: during a rollout, old and new pods briefly serve side by side.
  • No migration Job: on a fresh database the core creates its tables itself. Upgrades can need manual SQL, see Upgrading.
  • Probes: /hello for startup and readiness. It returns 200 only while the core can query the database, so during a database outage pods leave the Service instead of serving errors. Liveness is a TCP check, because restarting the core doesn't fix a database outage.
  • Several replicas: the core keeps no local state, so replicaCount can be raised. In our tests, two pods starting at once on an empty database created the schema without errors, and a rolling update under constant requests had no failed request.
  • Shutdown: the image's start script runs as PID 1 and ignores SIGTERM, which would leave every pod hanging until it's killed. The chart's preStop hook waits shutdownDelaySeconds (5) while the pod leaves the Service, then sends SIGTERM to the core, which shuts down cleanly.
  • Security: runs as the image's supertokens user (UID 1000) with a read-only root filesystem (the core's temp files go to an emptyDir), drops all capabilities, and doesn't mount a ServiceAccount token.
  • helm test checks /hello, that a call without the API key is refused (401) and that a call with it reads the database.

Upgrading

SuperTokens creates missing tables at startup but never adds columns to existing ones. Some versions therefore need SQL run by hand before the upgrade, listed under "Migration" in SuperTokens' CHANGELOG (e.g. 12.1.0 added two columns to session_info). Since 12.2.0 the core checks the schema at startup and, with supertokens.schemaCheckStrictMode: true (the default), refuses to start until the SQL has been run.

Before helm upgrade to a new SuperTokens version:

  1. Read the "Migration" sections of every version between yours and the new one.
  2. Run the SQL against your database (use CREATE INDEX CONCURRENTLY on large tables, as the notes say).
  3. Upgrade the chart.

If you miss a step, nothing breaks for your users. We tested 12.0.10 → 12.2.0 without the SQL: the new pod exits with Database schema is out of date and prints the exact ALTER TABLE statements in its log (kubectl logs), while the old pods keep serving and helm upgrade times out. After running those statements, the new pod started on its next restart and the rollout finished; existing users could sign in. Run helm upgrade once more to mark the release as deployed.

Production example

# values-prod.yaml
replicaCount: 3
supertokens:
  existingSecret: supertokens          # key: api-keys
  telemetry: false
database:
  existingSecret: supertokens-db       # key: uri
resources:
  requests: { cpu: 500m, memory: 512Mi }
  limits: { memory: 1Gi }
affinity:
  podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          topologyKey: kubernetes.io/hostname
          labelSelector:
            matchLabels: { app.kubernetes.io/name: supertokens }

Values

KeyTypeDefaultDescription
affinityobject{}Affinity.
database.existingSecretstring""Name of an existing Secret that holds the connection URI (recommended for production).
database.existingSecretKeystring"uri"Key in existingSecret that holds the connection URI.
database.schemastring""PostgreSQL schema for SuperTokens' tables (POSTGRESQL_TABLE_SCHEMA). Empty uses public.
database.uristring""Connection URI, e.g. postgresql://user:password@postgres:5432/supertokens (POSTGRESQL_CONNECTION_URI). Stored in a Secret created by this chart. Ignored when existingSecret is set.
extraEnvlist[]Extra environment variables. Every option in SuperTokens' config.yaml can be set by its upper-case name, e.g. ACCESS_TOKEN_VALIDITY, PASSWORD_HASHING_ALG, POSTGRESQL_CONNECTION_POOL_SIZE. See https://github.com/supertokens/supertokens-core/blob/master/config.yaml and https://github.com/supertokens/supertokens-postgresql-plugin/blob/master/config.yaml
extraEnvFromlist[]Extra environment variables from Secrets or ConfigMaps.
extraVolumeMountslist[]Extra volume mounts for the SuperTokens container.
extraVolumeslist[]Extra volumes for the pods.
fullnameOverridestring""Override the full resource name.
image.pullPolicystring"IfNotPresent"Image pull policy.
image.repositorystring"supertokens/supertokens-postgresql"Image repository. SuperTokens' official image for PostgreSQL.
image.tagstring""Image tag. Defaults to the chart's appVersion.
imagePullSecretslist[]Secrets for pulling from a private registry.
ingress.annotationsobject{}Ingress annotations.
ingress.classNamestring""Ingress class name.
ingress.enabledboolfalseCreate an Ingress. Usually not needed: only your backend talks to the core, never browsers or apps. If you enable it, keep supertokens.apiKeys set.
ingress.hostslist[{"host":"supertokens.example.com","paths":[{"path":"/","pathType":"Prefix"}]}]Ingress hosts and paths.
ingress.tlslist[]Ingress TLS configuration.
livenessProbeobject{"failureThreshold":3,"periodSeconds":10,"tcpSocket":{"port":"http"},"timeoutSeconds":5}Liveness probe. A TCP check on purpose: /hello fails while the database is down, and restarting the core doesn't help then.
nameOverridestring""Override the chart name in resource names.
nodeSelectorobject{}Node selector.
podAnnotationsobject{}Extra pod annotations.
podLabelsobject{}Extra pod labels.
podSecurityContextobject{"fsGroup":1000,"runAsGroup":1000,"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}}Pod security context. The image runs as the supertokens user, UID 1000.
readinessProbeobject{"failureThreshold":3,"httpGet":{"path":"/hello","port":"http"},"periodSeconds":5,"timeoutSeconds":3}Readiness probe on /hello. Pods leave the Service while they can't reach the database.
replicaCountint1Number of SuperTokens core pods. The core keeps no local state, so it scales horizontally.
resourcesobject{"limits":{"memory":"1Gi"},"requests":{"cpu":"100m","memory":"384Mi"}}Resources for the SuperTokens container. The core (Java) used about 200 MiB idle in our tests.
securityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}Container security context. The core's temp files go to emptyDirs, so the root filesystem is read-only.
service.portint3567Service port. SuperTokens' SDKs default to port 3567 in connectionURI.
service.typestring"ClusterIP"Service type.
serviceAccount.annotationsobject{}ServiceAccount annotations.
serviceAccount.automountboolfalseMount the ServiceAccount token. SuperTokens does not use the Kubernetes API.
serviceAccount.createbooltrueCreate a ServiceAccount.
serviceAccount.namestring""ServiceAccount name. Generated from the full name if empty.
shutdownDelaySecondsint5Seconds the pod waits after it's removed from the Service before the core is told to stop. The image's start script ignores SIGTERM, so the chart stops the core itself in a preStop hook.
startupProbeobject{"failureThreshold":60,"httpGet":{"path":"/hello","port":"http"},"periodSeconds":2,"timeoutSeconds":5}Startup probe on /hello, which answers only once the core is up and can query the database.
supertokens.apiKeysstring""API key(s) your backend SDK sends in the api-key header (API_KEYS). Comma-separated, each at least 20 characters of A-Z a-z 0-9 = -, e.g. from openssl rand -hex 32. Stored in a Secret created by this chart. Required unless existingSecret is set: without a key, anyone who can reach the Service can manage your users.
supertokens.existingSecretstring""Name of an existing Secret that holds the API key(s).
supertokens.existingSecretKeystring"api-keys"Key in existingSecret that holds the API key(s).
supertokens.logLevelstring""Log level (LOG_LEVEL): DEBUG, INFO, WARN, ERROR or NONE. Empty keeps SuperTokens' default (INFO).
supertokens.schemaCheckStrictModebooltrueRefuse to start while the database schema is missing tables or columns the core needs (SCHEMA_CHECK_STRICT_MODE). Keep it on: it stops an upgrade before it breaks logins. See "Upgrading".
supertokens.telemetrybooltrueSend anonymous usage telemetry to SuperTokens (DISABLE_TELEMETRY is set to the opposite).
terminationGracePeriodSecondsint30Seconds Kubernetes waits after the preStop hook before killing the container.
tolerationslist[]Tolerations.

Deploy supertokens with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has supertokens on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartsupertokens is pinned at v0.1.7 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply