# Install on Kubernetes

Source: https://docs.neode.sk/getting-started/kubernetes/
Last updated: 2026-12-03

> Run NeoDesk on Kubernetes with the Helm chart or plain manifests, as one replica or several that share PostgreSQL, Valkey and one volume.

The NeoDesk repository has a Helm chart in `deploy/helm/neodesk` and the same setup as plain manifests in `deploy/kubernetes`. Each pod runs the same image as the Docker install: signal, relay, API and web console in one process.

One replica needs nothing beyond a volume and runs on SQLite, as Docker does. Several replicas share one installation and need:

- PostgreSQL for the data. See [PostgreSQL](https://docs.neode.sk/operations/postgresql.md).
- Valkey 8 or Redis 7 for what the replicas share while they run: relay tickets, which pod holds which device, live events, sign-in steps.
- A volume all pods can write (`ReadWriteMany`: NFS, CephFS, EFS, Azure Files) for uploads, chat files, backups and the key pair.
- One public address, from a `LoadBalancer` Service, for every client port.

Several replicas need a server image with multi-replica support. Until it is part of a release, use `image.tag=dev`.

## Install with Helm

One replica:

```bash
git clone https://github.com/neodeskapp/neodesk.git
helm install neodesk neodesk/deploy/helm/neodesk -n neodesk --create-namespace \
  --set publicHost=<server-address>
```

`<server-address>` is the name or address clients use for the ID server and relay. Point it at the address the `neodesk` Service gets.

Three replicas, with `<server-address>` as above, `<db-password>` the PostgreSQL user's password and `<valkey-password>` the Valkey user's:

```bash
helm install neodesk neodesk/deploy/helm/neodesk -n neodesk --create-namespace \
  --set publicHost=<server-address> \
  --set replicaCount=3 \
  --set postgresql.url='postgres://neodesk:<db-password>@db:5432/neodesk?sslmode=require' \
  --set valkey.url='rediss://default:<valkey-password>@valkey:6379/0' \
  --set persistence.accessMode=ReadWriteMany
```

The chart refuses more than one replica when PostgreSQL, Valkey or a `ReadWriteMany` volume is missing, and says which. The server checks the same at its start: a second instance on SQLite or without Valkey stops and names what to set.

Then get the server's public key for the clients' Key setting, and the first admin's password:

```bash
kubectl -n neodesk exec deploy/neodesk -- cat /opt/neodesk/data/id_ed25519.pub
kubectl -n neodesk exec deploy/neodesk -- neodesk-show-admin-credentials
```

The web console runs on port 3375 of the `neodesk-web` Service. Set `ingress.enabled=true` and `ingress.host` to publish it, or `kubectl port-forward svc/neodesk-web 3375` to try it.

## What the chart sets up

| Part | What it does |
|---|---|
| Deployment | The replicas, one at a time on upgrades, spread over nodes where possible |
| Service `neodesk` | `LoadBalancer` with ports 21115 to 21119 (21116 over TCP and UDP) and 21121, with `externalTrafficPolicy: Local` so the server sees the clients' addresses |
| Service `neodesk-web` | The console and the API inside the cluster, for an Ingress |
| Secret | Random `API_KEY`, `SESSION_SECRET`, `JWT_SECRET`, `REMOTE_TARGET_VAULT_KEY` and cluster secret, kept across upgrades. Or bring your own with `secrets.existingSecret` |
| Volume | One claim for the server's and the console's files, kept when the release is removed |
| Probes | Ready when `/api/health` answers 200. Alive while the signal port accepts connections |
| PodDisruptionBudget | At least one replica during node drains |

Optional: `keyPair.existingSecret` brings an existing key pair (from a server you move to Kubernetes, so clients keep their Key setting), `tls.existingSecret` mounts a certificate for signal, relay and API, `valkey.enabled=true` starts a Valkey without persistence or password for tests, and `autoscaling.enabled=true` adds a HorizontalPodAutoscaler.

## How the replicas share the work

Every client port answers on every replica, so the load balancer can send a client to any of them:

- A device registers with whichever pod it reaches. The others find it in Valkey and pass messages for it to that pod.
- A relay session's two connections may reach different pods. The second one is passed to the pod where the first waits, so both sides of a session meet. Clients always get the same relay address.
- A console request for a CDAP device or a MeshCentral agent runs on the pod that holds the device's connection, terminal and file browser included.
- Background work (cleanups, alerts, scheduled backups, help request mail) runs on one pod at a time. If that pod stops, another takes over.
- Settings saved on one pod are read again by the others within a second.

## Upgrades and restarts

Upgrade with a new image tag, where `<tag>` is `latest`, `dev` or a release's version:

```bash
helm upgrade neodesk neodesk/deploy/helm/neodesk -n neodesk --reuse-values --set image.tag=<tag>
```

Kubernetes replaces one pod at a time and keeps the others serving. The first new pod updates the database while it holds a lock. In a cluster the console's own update and restart buttons are off and say so; restart all pods with `kubectl -n neodesk rollout restart deployment/neodesk`.

### Updating from 4.0.0-rc.1 or older

This update is a one-time full restart. Once the first new pod has changed the
database, pods of the older version fail on billing, telemetry, relay settings
and connection policies, so stop them all before the new version starts:

```bash
kubectl -n neodesk scale deployment/neodesk --replicas=0
kubectl -n neodesk get pods
```

Wait until the list shows no `neodesk` pod, then upgrade as above, with the new
version in place of `<tag>`, and scale back to the number of replicas you run,
in place of `<replicas>`:

```bash
helm upgrade neodesk neodesk/deploy/helm/neodesk -n neodesk --reuse-values --set image.tag=<tag>
kubectl -n neodesk scale deployment/neodesk --replicas=<replicas>
```

Remote sessions drop while no pod runs, and the clients reconnect once the new
pods are ready. Later updates replace one pod at a time again.

A stopping pod first reports not ready, takes no new sessions and gives running relay sessions `shutdownGraceSeconds` (30 by default) to end. Sessions whose connections meet on that pod end after that grace; the clients reconnect through the other pods within seconds. Sessions on other pods keep running.

## When Valkey goes away

Running sessions keep running. Every pod reports not ready, with the reason on `/api/health`, so the load balancer stops sending new connections and new sessions fail until Valkey answers again. The pods recover by themselves; they don't restart. Use a Valkey with a replica (or a managed one) in production.

## Without Helm

`deploy/kubernetes/neodesk.yaml` is the chart rendered for three replicas with an existing Secret. Its README lists the Secret to create and the two host names to change before `kubectl apply`. It always matches the chart.
