Skip to main content

Kubernetes (Helm)

Running auth-server for real, with more than one replica, rolling upgrades, and no single host to babysit by hand, calls for something more than docker compose up. The auth-server project ships a Helm chart for exactly that: deploying to a Kubernetes cluster, alongside whichever of MongoDB or PostgreSQL and Redis it needs, either bundled or pointed at instances you already run. See Docker Compose instead for local development or a small single-host deployment.

A chart is published to GitHub as oci://ghcr.io/rapidrest/charts/auth-server for every tagged release, versioned to match the release tag rather than the version checked into helm/Chart.yaml (CI overwrites it at package time). As of this writing no release has been tagged yet, check the packages page above for the current version once one exists.

Architecture

The chart deploys auth-server as a stateless Kubernetes Deployment, not a StatefulSet. Every replica is identical and runs behind a single Service, which is in turn exposed outside the cluster through a Gateway API Gateway/HTTPRoute rather than an Ingress. Each pod waits, via an init container, for its datastores to accept connections before starting.

------------ --------------- -----------
| Gateway | ---> | HTTPRoute | ---> | Service |
------------ --------------- -----------
|
-----------------------------------------------------------
| | |
------------ ------------ ------------
| Pod | | Pod | ... | Pod |
| (replica) | | (replica) | | (replica) |
------------ ------------ ------------
| | |
-----------------------------------------------------------
|
-----------------------------------
| |
------------ ------------
| MongoDB | | Redis |
| or | | (optional, |
| PostgreSQL | | standalone)|
| (optional, | ------------
| standalone)|
------------

MongoDB, PostgreSQL, and Redis are each optional, standalone Bitnami subcharts, bundled by default (mongodb.create/postgresql.create/redis.create). Point the chart at datastores you already run instead by setting the corresponding create to false and providing a connection URL. auth-server only ever uses one primary datastore at a time; see PostgreSQL below for how the chart picks between MongoDB and PostgreSQL when both are left enabled.

Prerequisites

  • Kubernetes 1.23+
  • Helm 3.8.0+
  • A Gateway API implementation with an nginx GatewayClass installed in the cluster (for example, NGINX Gateway Fabric). The chart deploys a Gateway/HTTPRoute, not an Ingress.
  • PV provisioner support in the underlying infrastructure, since the bundled MongoDB or PostgreSQL persists data to a PVC by default
  • cert-manager, if deploying with gateway.tls enabled (the default) against a public hostname. Skipped automatically for localhost or a .local hostname.

Dependencies

DependencyVersionDescription
@bitnami/mongodb18.4.8When MongoDB is desired.
@bitnami/postgresql18.8.13When PostgreSQL is desired.
@bitnami/redis24.1.8Required for cache, push, and sessions systems

Installing the Chart

helm install --create-namespace --namespace auth-server auth-server \
oci://ghcr.io/rapidrest/charts/auth-server \
--set host=auth.example.com

Add --version <x.y.z> to pin a specific release; omitted here, Helm installs whatever version was published most recently. host and --set overrides at install time cover most cases. See Parameters below for every configurable value.

Two-step install when provisioning your own datastores

When mongodb.create/postgresql.create/redis.create are left at their default, the chart reads the subcharts' generated credentials back out via a Helm lookup to build its own connection secrets. On a brand-new install, those subchart secrets don't exist yet at template-rendering time, so the API's pods will crash-loop immediately after install. Run helm upgrade once more, against the same chart reference you installed with, after the datastore pods are up, and the credentials will be picked up correctly. The chart's post-install notes cover this: run helm get notes auth-server -n auth-server to see them.

Uninstalling the Chart

helm uninstall auth-server --namespace auth-server

Configuration and installation details

General

host and environment drive most of the chart's other defaults: host sets the auth.audience/auth.issuer claims, the Gateway/HTTPRoute hostname, and the TLS certificate's domain, while environment sets NODE_ENV on the deployment. The JWT, cookie, and session secrets (auth.secret, cookies.secret, sessions.secret) are each randomly generated at install time if left unset, and preserved across upgrades via a Helm lookup against the previously generated Secret, so a helm upgrade never rotates them out from under running sessions.

Gateway

The chart attaches an HTTPRoute to a Gateway named by gateway.name/gateway.namespace. By default (api-gateway in the release's own namespace) it also creates that Gateway itself. Pointing gateway.name/gateway.namespace at a Gateway that already exists in another namespace skips creating a new one, letting multiple releases share a single Gateway. gateway.tls adds an HTTPS listener and requests a cert-manager certificate for host; gateway.hsts controls whether the Strict-Transport-Security header is left on the response, which is useful to disable for local or non-TLS testing.

Redis

Redis backs the cache, event bus, and log streaming, not primary data storage, so the bundled subchart runs without persistence (redis.master.persistence.enabled/redis.replica.persistence.enabled both default to false). Set redis.create to false and redis.url to point the deployment at a Redis instance you already run instead of the bundled one.

MongoDB

The application keeps its own data and its ACL data in two separate MongoDB databases (service.mongodb.mongo.name and service.mongodb.acl.name), which can point at the same server or different ones. As with Redis, set mongodb.create to false and mongodb.url (or the per-database service.mongodb.*.host/*.url overrides, if the ACL and application databases live on different servers) to use MongoDB instances you already run.

PostgreSQL

postgresql.create is the SQL-backed alternative to mongodb.create, off by default. The chart's datastore wiring checks mongodb.create first, so if you turn postgresql.create on you also need to turn mongodb.create off, otherwise the app is configured for MongoDB regardless of the PostgreSQL subchart also being deployed alongside it unused:

--set mongodb.create=false --set postgresql.create=true

Unlike MongoDB, PostgreSQL doesn't create a database the first time something connects to it, so only one database is auto-provisioned by the bundled subchart (postgresql.auth.database, rrst_auth by default) and used for the application data (service.postgresql.sql.name). The ACL datastore defaults to reusing the server's own built-in postgres database (service.postgresql.acl.name) rather than a dedicated one; provision a real database for it out-of-band and point service.postgresql.acl.name at it if you'd rather keep ACL data separate. As with MongoDB and Redis, set postgresql.create to false and postgresql.url (or the per-database service.postgresql.*.host/*.url overrides) to use a PostgreSQL instance you already run.

Service

service.image.registry/service.image.repository/service.image.tag select the container image; service.image.tag defaults to the chart's own appVersion field when left empty, which CI sets to match the release tag (the same one the chart itself is versioned and published under) at package time, so an unpinned install pulls the image matching whichever chart version you installed. service.resources and service.replicas are sized for a reference deployment, not production load, and should be tuned before real traffic. service.config and service.spec are escape hatches for anything the chart doesn't expose as its own parameter: service.config merges arbitrary key/value pairs into the service's environment configuration, and service.spec merges arbitrary fields into the pod spec (for example, nodeSelector or tolerations).

Parameters

NameDescriptionValue
hostPublic hostname the Gateway, HTTPRoute, and TLS certificate are issued forlocalhost
environmentSets NODE_ENV for the deploymentdev
auth.audienceJWT audience claim'{{ .Values.host }}'
auth.issuerJWT issuer claim'api.{{ .Values.host }}'
auth.expiresInAccess token lifetime1 hour
auth.secretJWT signing secret. Randomly generated at install time and preserved across upgrades'{{ randAlphaNum 32 }}'
cookies.secretCookie signing secret. Randomly generated at install time and preserved across upgrades'{{ randAlphaNum 32 }}'
sessions.secretSession secret. Randomly generated at install time and preserved across upgrades'{{ randAlphaNum 32 }}'
gateway.nameName of the Gateway the HTTPRoute attaches to. The chart only creates this Gateway itself when the name and namespace are both left at their defaults; point it at an existing Gateway to share one across releasesapi-gateway
gateway.namespaceNamespace of that Gateway'{{ .Release.Namespace }}'
gateway.tlsAdd an HTTPS listener and request a cert-manager certificate for host. Skipped automatically when host is localhost or ends in .localtrue
gateway.hstsKeep the Strict-Transport-Security response header. Set to false to strip it, for local or non-TLS testingtrue
redis.createDeploy a Redis instance via the Bitnami subcharttrue
redis.urlRedis connection URL. Override when redis.create is false to point at an external Redisredis://db-redis-master
redis.architectureRedis architecture, passed through to the Bitnami subchartstandalone
redis.auth.enabledRequire a password on the bundled Redistrue
redis.fullnameOverrideResource name prefix for the bundled Redis subchartdb-redis
redis.master.persistence.enabledEnable persistence on the Redis masterfalse
redis.replica.persistence.enabledEnable persistence on Redis replicasfalse
redis.networkPolicy.enabledCreate a NetworkPolicy restricting access to Redistrue
redis.networkPolicy.allowExternalAllow traffic from outside the cluster when networkPolicy.enabled is truefalse
mongodb.createDeploy a MongoDB instance via the Bitnami subcharttrue
mongodb.urlMongoDB connection URL, used only when mongodb.create is false""
mongodb.architectureMongoDB architecture, passed through to the Bitnami subchartstandalone
mongodb.auth.enabledRequire credentials on the bundled MongoDBtrue
mongodb.fullnameOverrideResource name prefix for the bundled MongoDB subchartmongodb
postgresql.createDeploy a PostgreSQL instance via the Bitnami subchart, as an alternative to mongodb.createfalse
postgresql.urlPostgreSQL connection URL, used only when postgresql.create is false""
postgresql.architecturePostgreSQL architecture, passed through to the Bitnami subchartstandalone
postgresql.fullnameOverrideResource name prefix for the bundled PostgreSQL subchartpostgresql
postgresql.auth.enablePostgresUserRequire credentials on the bundled PostgreSQLtrue
postgresql.auth.databaseName of the one database the bundled subchart auto-provisions on first startrrst_auth
service.image.registryContainer image registryghcr.io
service.image.repositoryContainer image repositoryrapidrest/auth-server
service.image.tagContainer image tag. Defaults to the chart's appVersion when empty""
service.imagePullSecretName of an existing image pull secret""
service.replicasNumber of replicas1
service.resources.requests.cpuCPU request100m
service.resources.requests.memoryMemory request256Mi
service.resources.limits.memoryMemory limit512Mi
service.mongodb.acl.nameDatabase name for the ACL datastoreaccess_control_lists
service.mongodb.acl.hostHost override for the ACL datastore""
service.mongodb.acl.urlFull connection URL override for the ACL datastore""
service.mongodb.mongo.nameDatabase name for the application datastorerrst_auth
service.mongodb.mongo.hostHost override for the application datastore""
service.mongodb.mongo.urlFull connection URL override for the application datastore""
service.postgresql.acl.nameDatabase name for the ACL datastorepostgres
service.postgresql.acl.hostHost override for the ACL datastore""
service.postgresql.acl.urlFull connection URL override for the ACL datastore""
service.postgresql.sql.nameDatabase name for the application datastorerrst_auth
service.postgresql.sql.hostHost override for the application datastore""
service.postgresql.sql.urlFull connection URL override for the application datastore""
service.configArbitrary key/value pairs merged into the service's environment configuration{logs: true, metrics: true, releaseNotes: true}
service.specArbitrary key/value pairs merged into the pod spec, for settings such as nodeSelector or tolerations{}

See also