Skip to content
NebulaCtrldocs

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

  1. Put TLS in front. Keep the default listen address, 127.0.0.1:8080, and terminate TLS at a reverse proxy. Use https:// as the base URL. The session cookie is marked Secure and named __Host-nebula_session only for an https:// 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 old nebula_session cookie until it ends; the control plane reads both names and writes only the new one. Do not pass --listen 0.0.0.0:8080 to the installer unless something else guards that port.
  2. Trust only your proxy. Set NEBULA_TRUSTED_PROXIES in .env, below the marker line, to the exact address or CIDR your proxy has from the container's side. Add cloudflare when Cloudflare sits in front. A trusted peer may set X-Forwarded-For, so restrict the origin to the proxy. CF-Connecting-IP is 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.
  3. Restrict who can read .env. It holds the master key, the database password, the OIDC client secret and the updater token. Keep mode 600. The installer's .env.bak-TIMESTAMP copies hold the same secrets, so remove the ones you no longer need.
  4. Limit host access. Anyone who can run docker or passwordless sudo on the host can read .env and the database. The nebula-updater service runs as the user that installed NebulaCtrl and drives Docker. Install as a dedicated user, or use --no-updater if you do not want console-triggered updates.
  5. Leave diagnostics closed. Metrics bind to the container's loopback. --pprof is off by default; do not turn it on in production.

Protect the database and the master key

  1. Keep PostgreSQL private. The bundled database is not published. For an external server, require TLS (for example sslmode=verify-full in the URL), allow only the control plane's address and encrypt the storage.
  2. Separate the key from the dump. Store .env or the master key apart from database dumps. A dump alone holds only sealed values.
  3. Rotate on a schedule. Follow Rotate the master key.

Lock down sign-in

  1. Use an https:// issuer. NebulaCtrl refuses a plain http:// issuer unless NEBULA_OIDC_INSECURE_HTTP is true. Never set that in production.
  2. 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.
  3. Keep invitation-only. People without an invitation or a SCIM grant are refused at sign-in. Revoke unused invitations; they expire after 7 days.
  4. Provision and deprovision over SCIM if your provider supports it. Deprovisioning revokes the tokens that person created.
  5. Review members. In Settings > Members, keep few owners and admins. The 2FA column shows who signed in without a second factor.
  6. 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.
  7. 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=login and max_age=0. A provider that ignores both and answers from an old sign-in is refused when it reports an auth_time older 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

  1. 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.
  2. Keep self-approval off. Approvers can't approve their own requests is on by default. Leave it on.
  3. Keep rollbacks reviewed. Rollbacks skip approval is off by default. Turn it on only with a reason.
  4. Freeze deploys when nobody is watching. Use Weekend deploy freeze. See Approvals and freezes.
  5. 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

  1. 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.
  2. Revoke what is unused. Any admin can revoke any token. A token can also revoke itself, whatever its role.
  3. 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.
  4. Rotate registry credentials by deleting and adding them. They cannot be edited.
  5. 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.
  6. 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.
  7. 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

  1. Install keys before you install NebulaCtrl. The cluster install disables SSH password login only if root or the sudo user already has an authorized_keys file. Otherwise it leaves password login on and says so.
  2. 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.
  3. 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/exec permission until you re-apply the install manifest.
  4. 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.
  5. Keep nodes patched. Unattended upgrades are installed on every node. You own reboots and the rest of the operating system.
  6. 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.

  1. 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 a proxy process that connects through the node's Tailscale. See What a pod can reach.
  2. Only Traefik and the agent reach a tenant's pods. Outside an environment, only the Traefik pod and the agent pod can reach its http and worker pods, and only on the ports its processes declare. A mesh grant is the one other path.
  3. A proxy upstream needs your permission to be private. A proxy process 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 *.suffix wildcard. Edit it under Clusters > the cluster > Settings > Tenant policy. See Set a cluster's tenant policy.
  4. 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.
  5. Environments run under the restricted Pod 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 user 0 then keeps its environment at restricted, with warn and audit also restricted and the version pinned. Without that support, a root process lowers its environment to baseline. To keep restricted on every cluster, leave processes on a non-root user. See Run a process as another user.
  6. 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.
  7. 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:

  1. Kernel-defaults protection. The script writes /etc/sysctl.d/90-nebula-kubelet.conf, reads the live values back and only then sets protect-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.
  2. An API audit log in /var/lib/rancher/k3s/server/logs/audit.log on 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.
  3. A Pod Security default of restricted for every namespace that carries no Pod Security label of its own. The script writes the policy to /var/lib/rancher/k3s/server/psa.yaml and passes it to the API server as its admission-control-config-file argument. These namespaces are exempt, because NebulaCtrl's own components run in them: kube-system, nebula-system, nebula-build, cnpg-system, cert-manager and tailscale. 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-namespaces on each server node and run the install command again.
  4. Default-deny network policies in the default and kube-public namespaces. A re-run skips a namespace that already runs pods and says so.
  5. Shorter-lived kubelet streams and finished pods. streaming-connection-idle-timeout is 5m and terminated-pod-gc-threshold is 100.

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.yaml whole, so a node installed by an earlier version, whose file names pod-security-admission-config-file, loses that key when you run the command again. K3s ignores that key, so the earlier install did not apply the restricted default.
  • Before the restart, it lists namespaces that run pods without a Pod Security label. A pod recreated there must meet the restricted standard 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.yaml
protect-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.log

Keep 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 -ltn
State   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/.env
600 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.started and shell.ended events only for people you expect.

Next steps

On this page