Harden a production install
A checklist for locking down a self-hosted NebulaCtrl control plane, its identity and access settings, its integrations and the clusters it manages.
A fresh install is safe by default: the control plane listens on loopback, the database is not published and .env is mode 600. This checklist covers what you add for production. Each item names the setting and how to check it.
Before you begin
- You have the owner role and shell access to the control plane host.
- Read the security model to see which parts are yours.
- Take a backup before you change anything on the host.
Secure the host and the edge
- Put TLS in front. Keep the default listen address,
127.0.0.1:8080, and terminate TLS at a reverse proxy. Usehttps://as the base URL. The session cookie is markedSecureand named__Host-nebula_sessiononly for anhttps://base URL: the__Host-prefix makes a browser refuse a copy planted by another subdomain. A session that signed in before an upgrade to 0.42.0 keeps its oldnebula_sessioncookie until it ends; the control plane reads both names and writes only the new one. Do not pass--listen 0.0.0.0:8080to the installer unless something else guards that port. - Trust only your proxy. Set
NEBULA_TRUSTED_PROXIESin.env, below the marker line, to the exact address or CIDR your proxy has from the container's side. Addcloudflarewhen Cloudflare sits in front. A trusted peer may setX-Forwarded-For, so restrict the origin to the proxy.CF-Connecting-IPis believed only from a peer you listed, never from loopback alone, and your proxy must overwrite both headers instead of forwarding a client's. Rate limits work per client address, so a wrong value either shares one limit across everyone or lets a client choose its own address. - Restrict who can read
.env. It holds the master key, the database password, the OIDC client secret and the updater token. Keep mode600. The installer's.env.bak-TIMESTAMPcopies hold the same secrets, so remove the ones you no longer need. - Limit host access. Anyone who can run
dockeror passwordlesssudoon the host can read.envand the database. Thenebula-updaterservice runs as the user that installed NebulaCtrl and drives Docker. Install as a dedicated user, or use--no-updaterif you do not want console-triggered updates. - Leave diagnostics closed. Metrics bind to the container's loopback.
--pprofis off by default; do not turn it on in production.
Protect the database and the master key
- Keep PostgreSQL private. The bundled database is not published. For an external server, require TLS (for example
sslmode=verify-fullin the URL), allow only the control plane's address and encrypt the storage. - Separate the key from the dump. Store
.envor the master key apart from database dumps. A dump alone holds only sealed values. - Rotate on a schedule. Follow Rotate the master key.
Lock down sign-in
- Use an
https://issuer. NebulaCtrl refuses a plainhttp://issuer unlessNEBULA_OIDC_INSECURE_HTTPis true. Never set that in production. - Require two-factor. Enforce multi-factor authentication at your provider and make it report
amr. Then switch on Require two-factor for everyone under Settings > Security & policy > Authentication. If your provider can issue hardware keys or passkeys, choose Hardware key or passkey only under Accepted second factors, so a text-message code does not count. See Manage members and teams. - Keep invitation-only. People without an invitation or a SCIM grant are refused at sign-in. Revoke unused invitations; they expire after 7 days.
- Provision and deprovision over SCIM if your provider supports it. Deprovisioning revokes the tokens that person created.
- Review members. In Settings > Members, keep few owners and admins. The 2FA column shows who signed in without a second factor.
- Shorten the session timeout. A session ends after 7 days without a request, and after 30 days whatever it does. Under Settings > Security & policy > Sessions, choose Sign out after a shorter limit, from 1 hour to 3 days, if your organization wants one. The shorter of that limit and the 7 days applies while a session acts in the organization. A person whose session ended is sent to sign in again.
- Make your provider honor a fresh sign-in. Creating a token, changing the security policy or the session timeout, making someone an admin, changing the recovery window and Delete now ask for a sign-in from the last 15 minutes. The console shows Confirm it's you and sends the person to the provider with
prompt=loginandmax_age=0. A provider that ignores both and answers from an old sign-in is refused when it reports anauth_timeolder than 15 minutes. To test it, sign in, wait 15 minutes, then create an API token: the console asks you to confirm, the provider asks for your credentials again, and you repeat the action. API tokens are never asked.
Constrain what changes can do
- Mark production environments as production when you create them. Changes to a production environment wait for an approval from an admin. Settings > Security & policy > Protected environments lists them.
- Keep self-approval off. Approvers can't approve their own requests is on by default. Leave it on.
- Keep rollbacks reviewed. Rollbacks skip approval is off by default. Turn it on only with a reason.
- Freeze deploys when nobody is watching. Use Weekend deploy freeze. See Approvals and freezes.
- Choose the recovery window. Deleting a service, database, volume, environment or project keeps its data, volumes and backups until the window ends. The default is 48 hours. Set it under Settings > Recently deleted > Recovery window, from Delete at once to 7 days. An admin ends the wait for one resource with Delete now. See Restore a deleted resource.
Manage API tokens and integrations
- Give each token the lowest role that works, limit it to the projects it needs, and pick an expiry. The table in Settings > API tokens tints tokens that never expire. Under Settings > Security & policy > API tokens, set the Longest token lifetime, so no token can live forever, and Allowed networks, so a leaked token is refused from anywhere but your CI's addresses. Rotate a token on its row when a secret may have been seen.
- Revoke what is unused. Any admin can revoke any token. A token can also revoke itself, whatever its role.
- Scope provider credentials. Use the GitHub App where you can. For GitLab and Forgejo, give the token only the scopes listed in Connect Git providers and registries. Give Cloudflare and object store credentials access only to the zones and buckets NebulaCtrl uses.
- Rotate registry credentials by deleting and adding them. They cannot be edited.
- Know what a token can read. A token with the Deployer role or higher reads a service's resolved variables, secrets in plain text. Give read-only integrations the Viewer role. Each secret returned is recorded in the audit log as
variable.revealed, by key and never by value. - Keep notification endpoints encrypted. A webhook channel accepts only an
https://URL without a user name or password, and its header values are write-only. The SMTP server connection is TLS from the first byte or STARTTLS before any password or message, and there is no unencrypted option. A webhook or mail host must resolve to a public address, and NebulaCtrl does not follow a webhook redirect. See Get notified about events. - Prove your generated domain base once. An admin sets the base under Settings > General > Generated domains. Ownership is proved when the TXT record shown there is found in public DNS. With a Cloudflare token that covers an active zone for the base, NebulaCtrl publishes the record itself; seeing the zone is not proof. Two organizations cannot prove the same base. See Add a custom domain.
Secure the clusters
- Install keys before you install NebulaCtrl. The cluster install disables SSH password login only if
rootor thesudouser already has anauthorized_keysfile. Otherwise it leaves password login on and says so. - Shorten join tokens. Under Settings > Security & policy > Server join tokens, set the default lifetime. The range is 5 minutes to 24 hours and the default is one hour.
- Keep agents current. The control plane never updates an agent on its own. See Update a cluster agent. An agent update changes only the agent's image, never its roles. A cluster installed before the browser shell has no
pods/execpermission until you re-apply the install manifest. - Remove clusters you no longer use. Removing a cluster stops its agent and broker tokens working. K3s stays installed until you run
/usr/local/bin/k3s-uninstall.sh. - Keep nodes patched. Unattended upgrades are installed on every node. You own reboots and the rest of the operating system.
- Decide who may open a shell. A shell runs as the container's user with the service's environment, so it reads every secret the service holds. Administrators, owners and API tokens with the Admin role can open one and browse files (Open a shell). A protected environment refuses it until you turn on Allow shell in protected environments under Settings > Security & policy > Change policy. It is off by default, also for an organization that existed before the setting. Turning it off ends open sessions within a minute. The activity log records who opened a shell, where and for how long, and each file listing, download and upload, but not what was typed.
Isolate tenants on a cluster
These hold on every cluster without a setting. Each item says what you can change.
- Tenant pods can't reach your network. Egress from an environment's pods excludes Tailscale and CGNAT space (
100.64.0.0/10), loopback, IETF protocol, benchmark and multicast ranges, IPv6 unique local and link-local addresses, the private LAN ranges and the node's own addresses. Only the node's public ports 80 and 443 stay reachable. DNS goes only to the cluster's DNS pods. You can't open these ranges to a pod. The one exception is a narrow rule for aproxyprocess that connects through the node's Tailscale. See What a pod can reach. - Only Traefik and the agent reach a tenant's pods. Outside an environment, only the Traefik pod and the agent pod can reach its
httpandworkerpods, and only on the ports its processes declare. A mesh grant is the one other path. - A proxy upstream needs your permission to be private. A
proxyprocess may publish a public address on its own. A private LAN, CGNAT or tailnet destination needs an entry in the cluster's upstream allowlist. Hosts inside the cluster, loopback, link-local and metadata addresses, and the cluster's own nodes and ranges are always refused. Keep the allowlist to the hosts you run, and prefer an address range or a host name over a*.suffixwildcard. Edit it under Clusters > the cluster > Settings > Tenant policy. See Set a cluster's tenant policy. - A volume can use only an allowed storage class. The cluster's default class, a class a volume there already uses, and the classes on the Storage class allowlist are accepted. Others are refused when the volume is created. Add a class under Tenant policy only after you know its isolation and expansion behavior.
- Environments run under the
restrictedPod Security level. Where a probe pod proves that the cluster supports user namespaces, the agent runs every pod with its own user namespace, so root in the container is an unprivileged user on the node. A process with Run as user0then keeps its environment atrestricted, withwarnandauditalsorestrictedand the version pinned. Without that support, a root process lowers its environment tobaseline. To keeprestrictedon every cluster, leave processes on a non-root user. See Run a process as another user. - Quotas and defaults bound each environment. A limit range gives containers a default request of 10m CPU, 16 MiB memory and 128 MiB ephemeral storage, and a default limit of 1 CPU, 1 GiB memory and 10 GiB ephemeral storage. A resource quota bounds CPU, memory, pods, Jobs, volume claims, requested storage and ephemeral storage, derived from the limits and volumes the services declare. Set tighter limits on a process to tighten its share. See Know the resource defaults and the namespace quota.
- Pods get no API token and no service-link variables. A cron run or a job that has not finished after 24 hours is stopped, and a cron process never runs two runs at once.
Harden K3s on the nodes
The cluster install script writes a K3s hardening profile. A new install gets it; an existing cluster gets it when you run its install command again, as described below. The profile sets:
- Kernel-defaults protection. The script writes
/etc/sysctl.d/90-nebula-kubelet.conf, reads the live values back and only then setsprotect-kernel-defaults: true. If a value cannot be set, it prints which one and leaves the protection off, because the kubelet refuses to start when the kernel disagrees. Fix the setting, then run the install command again. - An API audit log in
/var/lib/rancher/k3s/server/logs/audit.logon each server node. It rotates at 100 MB and keeps 10 files for up to 30 days. Every request is recorded with its metadata. Commands run in or opened to a pod, and changes to namespaces, roles and role bindings, are recorded with request and response. Secrets and service account tokens are recorded as metadata only: who touched one and when, never its value. The log stays on the node; NebulaCtrl does not forward it, so copy it off the node if you need it kept elsewhere. - A Pod Security default of
restrictedfor every namespace that carries no Pod Security label of its own. The script writes the policy to/var/lib/rancher/k3s/server/psa.yamland passes it to the API server as itsadmission-control-config-fileargument. These namespaces are exempt, because NebulaCtrl's own components run in them:kube-system,nebula-system,nebula-build,cnpg-system,cert-managerandtailscale. Environment namespaces keep the label NebulaCtrl gives them. To exempt a namespace of your own, put its name on its own line in/etc/nebula/psa-exempt-namespaceson each server node and run the install command again. - Default-deny network policies in the
defaultandkube-publicnamespaces. A re-run skips a namespace that already runs pods and says so. - Shorter-lived kubelet streams and finished pods.
streaming-connection-idle-timeoutis5mandterminated-pod-gc-thresholdis100.
Apply the profile to an existing cluster
Run the cluster's install command again on each node, as in Re-apply the manifest on an older cluster. The script compares the files it would write with the ones on the node:
- If nothing differs, it changes and restarts nothing.
- If something differs, it prints what changes (never the join token), copies the current files to
/etc/rancher/k3s/nebula-backup/TIMESTAMP/and keeps the five newest copies. It then says it is restarting K3s. The Kubernetes API is unavailable for a short time. Running workloads are not restarted. - If K3s refuses the new configuration, or is not ready 180 seconds after the restart, the script restores the backed-up files, restarts K3s again and ends with the error K3s gave. The node keeps its old configuration.
- The script writes
config.yamlwhole, so a node installed by an earlier version, whose file namespod-security-admission-config-file, loses that key when you run the command again. K3s ignores that key, so the earlier install did not apply therestricteddefault. - Before the restart, it lists namespaces that run pods without a Pod Security label. A pod recreated there must meet the
restrictedstandard from then on. Existing pods keep running.
Pinned downloads
The install script runs K3s's installer only after its SHA-256 matches the value written in the script, and the K3s release the installer downloads is checked against the release's checksum file. The Tailscale script downloads Helm as a release archive and checks its SHA-256 the same way. The CloudNativePG, Barman Cloud and cert-manager images are referenced by digest, and the agent image the control plane offers is a digest too. An agent update to an official image without a digest is refused by the cluster.
Check a node after the install:
grep -E 'protect-kernel-defaults|admission-control-config-file' /etc/rancher/k3s/config.yamlprotect-kernel-defaults: true
- "admission-control-config-file=/var/lib/rancher/k3s/server/psa.yaml"On a server node, confirm the audit log is written:
tail -n 1 /var/lib/rancher/k3s/server/logs/audit.logKeep the control plane current
Update when a release ships. Read the changelog first. See Upgrade the control plane.
Verify
Check the listener. Only loopback may appear for the control plane:
ss -ltnState Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 4096 127.0.0.1:8080 0.0.0.0:*Your proxy's port is listed too. Port 8080 must not show 0.0.0.0 or *, and 5432 must not appear.
Check the file mode:
stat -c '%a %U' /opt/nebula/.env600 deploy- Settings > Security & policy > Authentication shows Require two-factor for everyone on.
- Settings > API tokens lists no token you do not recognize.
- Settings > Members lists only people who need access.
- Settings > Security & policy > Change policy shows Allow shell in protected environments off, unless you need shells in production.
- Settings > Security & policy > Sessions shows the Sign out after limit you chose.
- Clusters > the cluster > Settings > Tenant policy lists only the upstream hosts and storage classes you expect.
- Activity lists
shell.startedandshell.endedevents only for people you expect.
Next steps
Security model
What NebulaCtrl secures, what you secure when you self-host it, and how the control plane, the agents, your identity provider and your Git providers trust each other.
Secrets and sealing
How NebulaCtrl encrypts stored secrets with envelope encryption, what the master key protects, how rotation and resealing work, and which values are never logged.