Ansible roles and playbooks that stand up ndmspc environments: a local kind or
minikube cluster (or a real one), Knative Serving on the istio/gateway-api
ingress, cert-manager, and the ndmspc server —
optionally as its room router (one Knative Service per room).
Everything runs through one playbook, playbooks/local.yml, driven by with_*
flags:
ansible-playbook playbooks/local.yml --tags install \
-e with_cluster=kind -e with_knative=true -e with_ndmspc=truepip install ansible kubernetes # ansible + the k8s python client
ansible-galaxy collection install kubernetes.core # used by the rolesThe roles fetch the tooling they need themselves (istioctl, kn, the
Knative/istio manifests, ...) into ~/.ndmspc/env; kubectl and a container
runtime (podman or docker — see container_tool) must be on the PATH, and
-e with_prerequisites=true installs the CLI tools listed by prerequisites
(kubectl, kind, minikube, kn, flux, vault, ...).
| Role | What it does |
|---|---|
prerequisites |
Installs the CLI tools named by the prerequisites list |
kind_cluster / minikube_cluster |
Creates the local cluster, with an optional local container registry (with_registry) |
cluster |
Cluster-side setup shared by the local profiles (registry, verification) |
istio |
istioctl + istiod + the ingress gateway, exposed on a fixed nodePort (kind/minikube) or a LoadBalancer (real clusters) |
knative |
Knative Serving (+ optional Eventing), the net-gateway-api gateways, the https/certificate flow, and the image-tag-resolution skip for a local registry |
certmanager |
cert-manager and the ACME ClusterIssuers (needed once with_https) |
ndmspc |
The ndmspc server on Knative — optionally as the room router |
keycloak, vault, velero, fluxcd, tekton, olm |
Optional extras, each behind its own with_* flag |
slurm |
Slurm on Kubernetes via the Slinky operator — operator + CRDs + a Slurm cluster, optionally login/accounting/metrics (with_slurm) |
config |
Writes the per-run configuration snapshot (see below) |
Most roles have their own README (roles/<name>/README.md) documenting their
variables, tags and usage — e.g. roles/ndmspc/README.md,
roles/knative/README.md,
roles/istio/README.md.
with_cluster selects the profile and everything else is derived from it:
with_cluster |
ingress | https | external URL |
|---|---|---|---|
kind / minikube |
istio (Gateway API, the default); -e with_ingress=nginx switches to kourier + nginx |
no | http://<domain>:8009 (host port → ingress nodePort) |
cern (real cluster) |
istio/gateway-api | yes | https://<ndmspc_domain> on the LoadBalancer |
with_ingress selects the ingress stack: istio (the default, Gateway API) or
nginx; knative_ingress follows it (istio → gateway-api, nginx →
kourier). with_ndmspc=true, with_keycloak=true and with_cluster=cern
require the istio ingress (the room router writes Gateway API HTTPRoutes;
keycloak is exposed through the knative-gateway; cern terminates https on the
gateway), and the playbook fails early when with_ingress=nginx is combined
with any of them. Pass -e container_tool=podman when that is your
runtime.
At the start of every run the play writes a snapshot of exactly the variables you
overrode via -e to configs/history/config-<date>-<time>.yaml under the directory
where ansible-playbook was executed (e.g.
configs/history/config-2026-09-09-143512.yaml, gitignored); the directory is
created when missing. You can point it elsewhere with
-e config_file=/path/to/config.yaml.
Use the snapshot on later runs so installs and applies share the same configuration (the end-of-run message prints the file's absolute path):
ansible-playbook playbooks/local.yml --tags install -e @configs/history/config-2026-09-09-143512.yaml
After the install, edit that file (e.g. bump ndmspc_version) and converge the
running cluster with --tags apply — no reinstall:
ansible-playbook playbooks/local.yml --tags apply -e @configs/history/config-2026-09-09-143512.yaml
The exported keys are controlled by config_export_keys /
config_export_defaults in roles/config/defaults/main.yml (e.g.
container_tool, ndmspc_image, ndmspc_version; extend the list there to
export more).
# kind cluster + Knative + the ndmspc server (this selects the istio ingress)
ansible-playbook playbooks/local.yml --tags install \
-e with_cluster=kind -e container_tool=podman \
-e with_knative=true -e with_ndmspc=true
# -> ndmspc is available at http://ndmspc.127.0.0.1.sslip.io:8009with_ndmspc is optional; without it the cluster comes up with Knative Serving
(and the istio Gateway API ingress) only. Keycloak can be added with
-e with_keycloak=true (add
-e keycloak_dev_init=true to also create its dev realm/client/user — see
Initialize the keycloak for local development),
and the ndmspc server can also be deployed in room mode with
-e ndmspc_room_router_enabled=true (see below).
To deploy an image built from a local ndmspc checkout, push it to the kind
registry and point the deployment at it — see the kind walkthrough in
roles/ndmspc/README.md.
Point ~/.kube/config at the cluster, then run with the cern profile:
istio/gateway-api ingress, https on the LoadBalancer, no local nodePort/host-port
mapping. You MUST provide the public hostname via ndmspc_domain.
# init: the platform the gateway needs (istio, cert-manager, knative) + the
# gateway + the LANDB/DNS gate; ends on a Ready letsencrypt-staging certificate
ansible-playbook playbooks/local.yml --tags init -e with_cluster=cern -e with_knative=true \
-e ndmspc_domain=ndmspc-dev.cern.ch -e certmanager_email=you@example.com
# once staging is Ready, switch the certificate to production
ansible-playbook playbooks/local.yml --tags init -e with_cluster=cern -e with_knative=true \
-e ndmspc_domain=ndmspc-dev.cern.ch -e certmanager_email=you@example.com -e prod=true
# install: the workloads (ndmspc, ...) - never touches the certificate
ansible-playbook playbooks/local.yml --tags install -e @configs/cern.yaml
--tags init is the platform + gateway pass: it installs what the gateway needs
(istio, cert-manager, knative) and owns the certificate and the LANDB gate — it
waits for the istio LoadBalancer IP, prints it together with the LANDB action
(alias + open ports 80/443 to the internet for let's encrypt), checks DNS for
ndmspc_domain and only asks until it resolves to that IP (no prompt at all when
it already does), then applies the gateway TLS and waits for the certificate. It
does not deploy the workloads (ndmspc, keycloak, slurm,
...) — that is --tags install. By default init ends on a Ready
letsencrypt-staging certificate (safe, and no production rate limits);
-e prod=true switches it to letsencrypt (production). install never touches
the certificate — it only (re)applies the gateway as it is — so the certificate
only ever changes on init (or with -e prod=true).
Requirements: the certmanager role (auto-enabled for with_cluster=cern)
ensures the ACME ClusterIssuers (the certificate itself is the init pass's job —
see above; -e istio_gateway_cert_issuer=<name> forces an issuer on any run).
CERN already runs cert-manager, so there the role only creates the ClusterIssuers;
on a cluster without it, the role installs cert-manager itself.
The Let's Encrypt account contact is passed via certmanager_email above. The
LANDB alias/DNS for ndmspc_domain must point at the istio ingress gateway's
LoadBalancer IP, with ports 80/443 open to the internet for the http-01
challenge. Let's Encrypt validates from outside, so internal reachability means
nothing here (a curl from inside CERN succeeds while the world is still blocked)
— check from several external locations (e.g. check-host.net), not locally. At
CERN the LANDB set/firewall change takes ~40 min to propagate, so the challenge
can keep timing out well after the ports look configured.
With -e ndmspc_room_router_enabled=true the ndmspc deployment becomes a room
router: it creates one Knative Service per room on demand and writes an
HTTPRoute per room, so users carrying ?room=<id> (HTTP or WebSocket) are sent
straight to that room's own instance.
BASE=http://ndmspc.127.0.0.1.sslip.io:8009 # the external URL from the install
curl -s -X POST -H 'Content-Type: application/json' -d '{"room":"abcd123"}' "$BASE/api/room/open" # add
curl -s "$BASE/api/room/list" # list
curl -s -X GET -H 'Content-Type: application/json' -d '{"room":"abcd123"}' "$BASE/api/room/status" # state
curl -s -X DELETE -H 'Content-Type: application/json' -d '{"room":"abcd123"}' "$BASE/api/room/close" # deleteRooms nothing has wanted for ndmspc_room_idle_ttl (default 24h) are deleted
automatically — unused meaning nothing asked the router about the room and its pod
is not running, so a room somebody is in is kept; rooms are created with
min-scale 0, so an idle room keeps its Service but runs
no pods. The clock that counts down is kept on the room's own Service, so a router
that is rolled (an apply, a new image) resumes each room's remaining time instead
of handing every room a fresh TTL.
How long a room's pod outlives its last use is Knative's own autoscaler, and the
knative role owns those settings (knative_stable_window,
knative_scale_to_zero_grace_period, knative_scale_to_zero_pod_retention_period
— Knative's defaults, so about 90s); both cluster configs show them commented. See
roles/ndmspc/README.md for the full API,
the router variables and the kind walkthrough.
Every timer a request travels through, outermost first. The rule that matters: the outermost
timeout that applies to a connection wins, so raising an inner one does nothing while an outer one
is shorter — which is exactly how a room's WebSocket used to be cut every five minutes by Knative's
response-start timeout (300s) while the room's own timeoutSeconds was already 3600s.
roles/knative/defaults/main.yml — patched into configmap/config-defaults in knative-serving
(by the install tag) and roles/knative/README.md has the same list.
| Knob | Default | Bounds | Tune when |
|---|---|---|---|
knative_revision_timeout_seconds |
300 |
the whole request/stream a revision may take | one action or stream must outlive 5 min; rooms override it per room (below) |
knative_revision_response_start_timeout_seconds |
0 (never) |
how long a response may take to begin — for a WebSocket this is the whole stream | leave at 0: Knative's 300 default cut every room's socket, and every client re-listed its pages, every 5 min |
knative_revision_idle_timeout_seconds |
0 (never) |
an open connection with no traffic | leave at 0 — a WebSocket is idle by nature |
knative_max_revision_timeout_seconds |
3600 |
the ceiling a workload's own timeoutSeconds must fit under |
raise together with ndmspc_room_timeout_seconds |
knative_stable_window |
60s |
autoscaler window before it decides to scale a room in | rooms should linger / free the cluster sooner |
knative_scale_to_zero_grace_period |
30s |
how long the last pod is kept after that decision | as above (a room's pod is gone ~90s after its last use) |
knative_scale_to_zero_pod_retention_period |
0s |
minimum retention of the last pod | as above |
For completeness, in the ingress (istio's Envoy, read from the running gateway): stream_idle_timeout
and the route timeout are both 0s (disabled) and connect_timeout is 10s — none of these cuts a
room's socket today.
roles/ndmspc/defaults/main.yml — the room/entry shape. A room pins its revision and these
values, so a change reaches an existing room only when it is re-created or upgraded.
| Knob | Default | Bounds | Tune when |
|---|---|---|---|
ndmspc_room_timeout_seconds |
3600 |
timeoutSeconds on the entry Service and in every room |
a session must outlive an hour (bounded by knative_max_revision_timeout_seconds) |
ndmspc_room_idle_ttl |
24h |
NDMSPC_ROOM_IDLE_TTL: when an unused room is swept (in use = its pod runs, a WebSocket counts) |
retire idle rooms sooner (e.g. 1m while testing) |
ndmspc_room_watch_interval |
0s |
NDMSPC_ROOM_WATCH_INTERVAL: how often the rooms list is pushed to a watcher |
off by default, so a deployment opts in (a tick reads the cluster once per distinct caller, and each watcher holds a router thread); set e.g. 5s to serve pushes |
ndmspc_rooms_restore_timeout |
600 |
how long a restore may take overall (each room it creates waits ~45s for its revision) | restoring many rooms in one go |
ndmspc_room_max_connections |
100 |
not a timeout: concurrent requests one room pod accepts | a bigger room holds more members |
The router's own knobs (http/room/NRoomRouter.h in ndmspc) — NDMSPC_ROOM_READY_TIMEOUT (45s, how
long it waits for a room's first revision; a room still unschedulable when it runs out stays pending
rather than being deleted), NDMSPC_ROOM_IDLE_TTL and NDMSPC_ROOM_WATCH_INTERVAL above,
NDMSPC_ROOM_MAX_PREPARING (4 rooms being created or waiting for resources at once, the
backpressure), NDMSPC_ROOM_PENDING_TTL (30m before a wait nobody could satisfy is reported failed,
its Service kept; 0 waits for ever), NDMSPC_ROOM_WAKE_PROBE / NDMSPC_ROOM_CAPACITY_TTL (whether
an idle room is probed for somewhere to start, and how long that capacity snapshot is reused), and
NDMSPC_ROOM_WAIT (the default for room/open's wait). The devops knobs above render all of them
into the router's environment.
The room server (ndmspc-server, http/README.md in ndmspc):
| Option / env | Default | Bounds |
|---|---|---|
--heartbeat |
10000 ms |
how often each client is sent a heartbeat |
--oidc-auth-timeout (NDMSPC_OIDC_AUTH_TIMEOUT_SECONDS) |
15 s |
how long a WebSocket may take to authenticate before it is closed |
The browser client (ndmspc-ui, src/lib/room/**) — the innermost layer, and the one that decides
what the user sees:
| Constant | Default | Bounds |
|---|---|---|
LIVENESS_MS |
30s |
server silence after which the socket is taken for lost (server heartbeats are 10s) |
CONNECTED_GRACE_MS |
2.5s |
how long an anonymous welcome may take before the server is taken for auth-enabled |
DEFAULT_AUTH_TIMEOUT_MS |
10s |
the authenticate reply |
DEFAULT_REQUEST_TIMEOUT_MS |
1h |
an action's reply (per request, or the room's timeoutMs prop); an action may declare its own, 0 meaning no limit, and Cancel ends the wait |
| reconnect delay | 1s → 30s |
between attempts after a lost socket (doubles, resets on open) |
OVERLAY_DELAY_MS |
300ms |
before the blocking "please wait" overlay appears |
room-list poll (DEFAULT_REFRESH_SECONDS) |
2s |
fallback refresh when the router's watch socket is not carrying the list |
| token refresh loop | every 60s, refreshing under 60s of validity |
sign-in only; a refresh re-authenticates on the live socket and never drops it |
| keycloak init / login / probe | 3s / 8s / 3s |
the sign-in phase |
| OIDC token request | 15s |
calls to the token endpoint |
Changing one:
- Knative defaults: edit
roles/knative/defaults/main.yml(+ the README table) and re-apply —--tags applyre-patchesconfig-defaults(config_defaults.yml) andconfig-autoscaler(autoscaler.yml); theinstalltag does too. Raiseknative_max_revision_timeout_secondstogether withndmspc_room_timeout_seconds, or the Knative webhook rejects a room'stimeoutSeconds. Existing rooms keep the values their revision was stamped with. - A room's shape: edit
roles/ndmspc/defaults/main.yml(or pass-e) and--tags apply, then re-create or upgrade the rooms — a room's revision, image and timeouts are pinned until it is rolled. - Server / client: the heartbeat is an image option (env/args); the client constants are compiled into the page, so they need the page rebuilt.
To see which one fired: the room's Logs panel in the UI lists the connection's own lines
(connect, close, timeout = "nothing from the server", retry = reconnecting in N ms). From the
cluster: kubectl -n knative-serving get cm config-defaults -o yaml,
kubectl -n default get ksvc <room> -o jsonpath='{.spec.template.spec.timeoutSeconds}', and the
queue-proxy's own view of it:
kubectl -n default get pod <room-pod> -o jsonpath='{.spec.containers[?(@.name=="queue-proxy")].env}'.
An image carries the published ndmspc-ui page (ui/README.md in the ndmspc
repo). To serve a page built from a working tree — the way to test a UI change
before it is released — scripts/local-image.sh builds
the library and the page, puts it on top of the base image and applies the cluster:
(cd ../ndmspc-ui && npm run build) # the script does this
devops/scripts/local-image.sh # --base rebuilds the server image tooIt tags every run uniquely (local-<timestamp>), because a Knative Service only
rolls when its pod template changes: a tag that stays the same while the image
under it does not means the running pods keep the image they were started with.
After the initial install, converge the running cluster to a new configuration
(revision/WebSocket timeouts, ndmspc_domain, autoscaling, ndmspc_image, room
mode, https) without re-downloading, removing or re-running heavy
installs (istioctl, knative CRDs, eventing, ...) — see the configuration file
section above, or pass the changed variables directly:
ansible-playbook playbooks/local.yml --tags apply -e with_cluster=cern -e with_knative=true \
-e with_ndmspc=true -e ndmspc_domain=ndmspc-dev.cern.ch \
-e ndmspc_image=registry.gitlab.com/ndmspc/ndmspc/base:next
What apply runs:
ndmspc— re-render + apply the ndmspc Knative Service manifest in place (rolls a new revision for image/domain/autoscaling/room-mode changes) and waits Ready. In room mode (ndmspc_room_router_enabled) it also applies the router RBAC and the room skeleton.knative— re-apply the gateway TLS/issuer (gateway_tls.yml): re-renders the knative-gateway with the current https, keeps the issuer already on the cluster and waits for the Certificate (-e prod=trueswitches it toletsencryptand waits for that). It also (re-applies) the local-registry tag-resolution skip.istio/certmanager— nothing underapply.
Tags across the roles: init (platform + ingress only: istio, cert-manager,
knative, the knative gateway and its certificate — on a real cluster it also owns
the LANDB/DNS gate and ends on a Ready letsencrypt-staging certificate,
-e prod=true for production; it does not deploy the workloads), install
(the workloads — ndmspc, keycloak, slurm, ... — and the platform, but it never
touches the certificate), apply (lightweight in-place convergence), clean
(remove what the role created — the ndmspc usage-history PVC is deliberately
kept, see roles/ndmspc), verify (check the deployed resources exist).
ansible-playbook playbooks/verify.yml -e @configs/kind.yaml
Runs against a cluster that is already deployed (it does not need this directory to
have installed it) and only reads state, apart from one short batch job and one
throwaway room, both removed at the end. On any cluster it creates and deletes a room
through the router (the room lifecycle — no Slurm needed). The Slurm-specific checks
below need with_slurm=true (or a profile that sets it); without it they are skipped
with a message:
- the Slurm pods are Ready, and it prints the images they run
- a compute node is up and runs a job (
srun), and whether it carries ndmspc + ROOT - a batch job completes and its log can be read from the node it ran on
- a room opens, answers
/api/slurm/*through the router, submits a job, reports it COMPLETED and checks the job is recorded as the Slurm account the rooms submit as
It stops at the first failed check with the fix to try - a node left down, a job
held because slurmctld cannot resolve the submitting user, or a room job recorded as
another user (the rooms submit over REST with the SlurmUser's token; see the ndmspc
role). The room checks are skipped with a warning when the entry URL is not reachable
from where you run it; point it at one with -e ndmspc_domain=<hostname> -e ndmspc_external_port=<port>. Each run opens its own room, so it never collides with
a room you have open.
Check 4 goes through the entry's /api, which a deployment with OIDC authenticates, so
there it needs a bearer token from that issuer as well: pass
-e ndmspc_verify_bearer_token=<token> or -e ndmspc_verify_bearer_token_file=<path>
(CERN: auth-get-user-token -c public-client -o token.txt). Without either it says so
and skips the room checks - the Slurm checks 1-3 do not need it, they use kubectl.
Installing with -e with_keycloak=true -e keycloak_dev_init=true configures
keycloak as part of the install (the keycloak role runs the dev-init tasks):
ansible-playbook playbooks/local.yml --tags install \
-e with_cluster=kind -e container_tool=podman \
-e with_knative=true -e with_ndmspc=true \
-e with_keycloak=true -e keycloak_dev_init=true
keycloak is always exposed through the istio (Gateway API) knative-gateway: the
role creates an HTTPRoute and keycloak is at
http://keycloak.127.0.0.1.sslip.io:8009 (kind host port 8009 → the ingress
gateway nodePort). There is no nginx fallback — the install needs the istio
gateway (with_knative=true with the default with_ingress=istio), and the
playbook fails early when keycloak is enabled without it.
For a keycloak that is already running, the standalone playbook configures it the same way (it runs the same tasks):
ansible-playbook playbooks/keycloak-dev-init.yml
Both create the ndmspc-dev realm, the ndmspc-dev-client public client with
the ndmspc audience mapper the NDMSPC server expects, and an ndmspc test
user. The settings are the keycloak_dev_init_* defaults in
roles/keycloak/defaults/main.yml and are overridable with -e, e.g.
-e keycloak_dev_init_url=http://keycloak.example:8009.
keycloak_dev_init_idps in the same defaults file lists the providers the dev
realm can broker: CERN (generic OIDC, with its endpoints configured), Google and
GitHub (Keycloak's built-in social providers, which only need a client
id/secret). Each entry is off until enabled and needs credentials, which are read
in order from an inline client_id / client_secret on the entry, a KEY=VALUE
file given as -e keycloak_dev_init_idps_env_file=<file>, or the environment
variable named by client_id_env / client_secret_env — so no secret lives in
the repo. roles/keycloak/files/idp.env.example lists every variable; copy it
outside the repository and fill in what you use. A provider whose two variables
are empty (or missing) is left disabled, so leaving the rest blank is fine.
Register a client at the provider whose redirect URI is
http://keycloak.127.0.0.1.sslip.io:8009/realms/ndmspc-dev/broker/<alias>/endpoint,
then enable the provider by alias for one run:
# credentials from the environment
export CERN_OIDC_CLIENT_ID=... CERN_OIDC_CLIENT_SECRET=...
ansible-playbook playbooks/keycloak-dev-init.yml \
-e keycloak_dev_init_idps_enabled=cern
# ...or from a KEY=VALUE file (values may be quoted; '~' is expanded)
ansible-playbook playbooks/keycloak-dev-init.yml \
-e keycloak_dev_init_idps_enabled=cern \
-e keycloak_dev_init_idps_env_file=~/.ndmspc/cern-idp.env
Several can be listed at once (-e keycloak_dev_init_idps_enabled=cern,google).
A provider that is enabled without credentials is reported with what to set
instead of failing the run. The UI then offers one sign-in button per provider —
list the aliases in VITE_KEYCLOAK_IDPS, e.g.
"cern|CERN via NDMSPC,google|Google,github|GitHub".