Deploy with k8s

On this page

Kubernetes is an open-source container orchestration system that automates application deployments. Kubernetes restarts failed containers, scales workloads, and rolls deployments out and back. Kubernetes runs Docker images, so you can deploy the FusionAuth Docker image to any Kubernetes cluster.

This guide deploys FusionAuth with a Helm chart and kubectl, the Kubernetes command-line tool that sends commands to a cluster through the API server.

Requirements#

Add the Helm Chart Repository#

Add the FusionAuth Helm chart repository:

$ helm repo add fusionauth https://fusionauth.github.io/charts

To confirm that Helm added the repository, list your repositories:

$ helm repo list

The list includes the fusionauth repository:

NAME      	URL
fusionauth	https://fusionauth.github.io/charts

To see the chart versions in the repository, search the repository:

$ helm search repo fusionauth

The search returns the FusionAuth chart:

NAME                 	CHART VERSION	APP VERSION	DESCRIPTION
fusionauth/fusionauth	1.69.4       	1.69.4     	Helm chart for FusionAuth

Configure the Helm Chart#

Before you install, create a values.yaml file that holds the chart values you want to change. Helm merges values.yaml with the chart's defaults, so values.yaml only needs the values that differ. This guide covers the values you must set to deploy FusionAuth.

To review every option and the option's default, save the chart's default values to a separate file:

$ helm show values fusionauth/fusionauth > chart-values.yaml

Replicas#

The replicaCount value sets the number of FusionAuth instances to run in a ReplicaSet. Kubernetes keeps that number of instances running at all times.

The default replicaCount is 1, which works for development and testing. For production, set replicaCount to fit your traffic and availability requirements:

values.yaml
# replicaCount -- The number of fusionauth-app instances to run
replicaCount: 1

FusionAuth Version#

Each chart release sets image.tag to the FusionAuth version that the chart release shipped with, so helm install installs that version. To run a different version, set image.tag in values.yaml to one of the FusionAuth releases. Use a specific version instead of latest, so every pod runs the same release.

Extra Containers#

To add a sidecar or ambassador container to the FusionAuth pod, use the extraContainers value. For example, a proxy sidecar can serve FusionAuth at a different path, or limit the IP addresses that can reach the Admin UI:

values.yaml
extraContainers:
  - name: my-sidecar
    image: nginx:stable

For proxy configurations from the community, see fusionauth-contrib.

Database Configuration#

Every FusionAuth pod uses the database configuration to connect to the database.

Note

FusionAuth requires an external database. Elasticsearch is optional. This guide doesn't cover setting up either service. For instructions for AWS, GCP, and other providers, see the setup guides.

Store the database passwords in Kubernetes Secrets instead of in values.yaml, so the passwords stay out of version control and your Helm release history. Create one Secret for the password FusionAuth uses in normal operation, and one for the database superuser password FusionAuth uses to create the FusionAuth database:

$ kubectl create secret generic fusionauth-db-credentials --from-literal=password='<fusionauth-user-password>'
$ kubectl create secret generic fusionauth-db-root-credentials --from-literal=password='<superuser-password>'

Then add a database section to values.yaml with your database host and user names, and reference the Secrets:

values.yaml
database:
  host: "<database-host>"
  port: 5432
  protocol: postgresql
  tls: true
  tlsMode: require
  name: fusionauth

  dbUser:
    username: fusionauth
    existingSecret:
      enabled: true
      name: fusionauth-db-credentials
      passwordKey: password

  rootUser:
    username: "<superuser-name>"
    existingSecret:
      enabled: true
      name: fusionauth-db-root-credentials
      passwordKey: password

During initial setup, FusionAuth uses the rootUser credentials to create the fusionauth database and the dbUser user. When you set up the database yourself, follow the advanced database installation guide, then remove the rootUser section and the superuser Secret.

The tlsMode: require setting encrypts the database connection, but doesn't verify the database server's certificate. To verify the certificate, mount your database provider's CA certificate into the pod with extraVolumes and extraVolumeMounts. Then set database.url to a full JDBC URL that uses sslmode=verify-full. When database.url is set, the chart ignores tls and tlsMode. For an example URL, see database.url in the configuration reference.

Search Configuration#

When search.engine is set to elasticsearch, add a search section to values.yaml with your search host. Use https when your search service supports HTTPS. When your search service doesn't require a username and password, leave out basicAuth:

values.yaml
search:
  engine: elasticsearch
  protocol: https
  host: "<search-host>"
  port: 9200
  basicAuth:
    existingSecret:
      enabled: true
      name: fusionauth-search-credentials
      userKey: username
      passwordKey: password

Store the search credentials in a Secret, like the database passwords:

$ kubectl create secret generic fusionauth-search-credentials --from-literal=username='<search-username>' --from-literal=password='<search-password>'

Runtime and Silent Mode#

Set the runtime mode to production and turn on silent mode. In silent mode, FusionAuth creates the database on first start and applies database migrations during updates. Nobody needs to complete Maintenance Mode in a browser:

values.yaml
app:
  runtimeMode: production
  silentMode: true

Kickstart#

To start FusionAuth with a configuration in place, use Kickstart. Kickstart completes the initial setup, so FusionAuth skips the Setup Wizard. The Kickstart file must create an admin user, or nobody can log in to the Admin UI. Kickstart only runs against an empty database, so the Kickstart file only takes effect on the first install.

Keep the API key and the admin password in a Secret, so the values stay out of values.yaml and your Helm release history. Use long random values, such as the output of openssl rand -hex 32:

$ kubectl create secret generic fusionauth-kickstart --from-literal=api-key='<api-key>' --from-literal=admin-password='<admin-password>'

Then add the following to values.yaml, and replace <admin-email> with the email address of your admin user. The environment value exposes each Secret key to the FusionAuth container as an environment variable. The Kickstart file reads each variable with #{ENV.VARIABLE_NAME}. The Kickstart request registers the admin user to the FusionAuth application with the admin role:

values.yaml
environment:
  - name: FUSIONAUTH_API_KEY
    valueFrom:
      secretKeyRef:
        name: fusionauth-kickstart
        key: api-key
  - name: FUSIONAUTH_ADMIN_PASSWORD
    valueFrom:
      secretKeyRef:
        name: fusionauth-kickstart
        key: admin-password

kickstart:
  enabled: true
  data:
    kickstart.json: |
      {
        "apiKeys": [
          {
            "key": "#{ENV.FUSIONAUTH_API_KEY}",
            "description": "Initial API key"
          }
        ],
        "requests": [
          {
            "method": "POST",
            "url": "/api/user/registration",
            "body": {
              "user": {
                "email": "<admin-email>",
                "password": "#{ENV.FUSIONAUTH_ADMIN_PASSWORD}"
              },
              "registration": {
                "applicationId": "#{FUSIONAUTH_APPLICATION_ID}",
                "roles": ["admin"]
              }
            }
          }
        ]
      }

To keep other values out of values.yaml, add a key to the Secret and an environment entry for the key, then reference the variable in the Kickstart file. For the full Kickstart syntax, see Using Environment Variables.

Deploy FusionAuth to the Cluster#

Install the chart with values.yaml. The -f flag passes values.yaml to Helm:

$ helm install my-release fusionauth/fusionauth -f values.yaml
Note

You can also override individual values with the --set flag on the command line. The --set flag helps in scripts and command-line tools.

When the install succeeds, Helm prints output similar to the following:

NAME: my-release
LAST DEPLOYED: Tue Nov  3 13:26:58 2026
NAMESPACE: default
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export SVC_NAME=$(kubectl get svc --namespace default -l "app.kubernetes.io/name=fusionauth,app.kubernetes.io/instance=my-release" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:9011 to use your application"
  kubectl port-forward svc/$SVC_NAME 9011:9011

To check the status of the deployment, list the deployments on the cluster:

$ kubectl get deployments -o wide

The READY column shows the number of running FusionAuth pods:

NAME                    READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                                       SELECTOR
my-release-fusionauth   1/1     1            1           21s   fusionauth   docker.io/fusionauth/fusionauth-app:1.69.4   app.kubernetes.io/instance=my-release,app.kubernetes.io/name=fusionauth

To connect to FusionAuth from localhost, forward a local port to the FusionAuth service:

$ export SVC_NAME=$(kubectl get svc --namespace default -l "app.kubernetes.io/name=fusionauth,app.kubernetes.io/instance=my-release" -o jsonpath="{.items[0].metadata.name}")
$ kubectl port-forward svc/$SVC_NAME 9011:9011

kubectl prints the forwarded port:

Forwarding from 127.0.0.1:9011 -> 9011

Navigate to http://localhost:9011. When you configured Kickstart, log in with the admin user from the Kickstart file. Otherwise, FusionAuth shows the Setup Wizard. For a walkthrough of the initial FusionAuth configuration, see Setup Wizard & First Login.

The Setup Wizard with the admin user details filled in.
The Setup Wizard with the admin user details filled in.

Expose FusionAuth Through a Gateway#

To let users reach FusionAuth from outside the cluster, route traffic to FusionAuth with the Gateway API, the Kubernetes API for bringing external traffic into a cluster. The FusionAuth chart can create the route for you.

A Gateway needs a controller that implements the Gateway API. This guide uses Envoy Gateway. Most cloud providers also offer an implementation, such as the GKE Gateway controller. To use another implementation, install the implementation instead of Envoy Gateway, and use the implementation's GatewayClass in gateway.yaml.

Install Envoy Gateway#

Install Envoy Gateway, which also installs the Gateway API resource definitions:

$ helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.9.3 -n envoy-gateway-system --create-namespace

Then wait until Envoy Gateway is ready:

$ kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available

Create the Gateway#

The Gateway terminates TLS, so the Gateway needs a certificate for your FusionAuth hostname. Store the certificate and private key in a TLS Secret, or use cert-manager to issue and renew a certificate:

$ kubectl create secret tls fusionauth-tls --cert=tls.crt --key=tls.key

Next, create a file named gateway.yaml with the following resources:

  • A GatewayClass that assigns Gateways of the class eg to Envoy Gateway.
  • A Gateway with an HTTPS listener that uses your TLS Secret, and an HTTP listener.
  • An HTTPRoute that redirects every HTTP request to HTTPS.
gateway.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: eg
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: fusionauth-gateway
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      hostname: auth.example.com
    - name: https
      protocol: HTTPS
      port: 443
      hostname: auth.example.com
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: fusionauth-tls
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: fusionauth-http-redirect
spec:
  parentRefs:
    - name: fusionauth-gateway
      sectionName: http
  hostnames:
    - auth.example.com
  rules:
    - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
            statusCode: 301

Replace auth.example.com with your FusionAuth hostname, then apply the file:

$ kubectl apply -f ./gateway.yaml

Route Traffic to FusionAuth#

Add a gateway section to values.yaml, using the same hostname. The chart then creates an HTTPRoute that sends requests from the Gateway's HTTPS listener to FusionAuth:

values.yaml
gateway:
  enabled: true
  parentRefs:
    - name: fusionauth-gateway
      sectionName: https
  hostnames:
    - auth.example.com

Apply the change by upgrading the release:

$ helm upgrade my-release fusionauth/fusionauth -f values.yaml

Finally, get the Gateway's external address:

$ kubectl get gateway fusionauth-gateway

The ADDRESS column shows the external address:

NAME                 CLASS   ADDRESS        PROGRAMMED   AGE
fusionauth-gateway   eg      203.0.113.10   True         2m

Point the DNS record for your FusionAuth hostname at the address. On a cloud provider, the address belongs to a load balancer that Envoy Gateway created for the Gateway.

Note

On minikube, run minikube tunnel to create a network route to your cluster and give the Gateway an address. For more information, see Using minikube tunnel.

Troubleshooting#

Runtime Mode Mismatch#

If you receive a message similar to this one in your system log:

ERROR io.fusionauth.api.service.system.NodeService - Node [c98263dc-7f12-4879-93c1-f1a634912a51] cannot be added. The runtime mode is [Development] and this node in [Production] mode.

This means that your nodes are in different runtime modes. This will not work and may cause undetermined behavior. All nodes of a FusionAuth cluster must be running in the same mode, either Production or Development.

To resolve this issue, take the following steps:

  • Stop all existing nodes, whether they are running as containers or processes.
  • Review configuration to confirm that all nodes are configured with the same runtime mode.
  • Restart the nodes.

Next Steps#

Before customers log in to this instance, change the FusionAuth settings in Harden a Production Instance. To secure the cluster itself, see the Kubernetes security documentation. For more on running a cluster, see Kubernetes Concepts, Configuration Best Practices, and the Helm documentation.