Skip to content

feat(netbird): read-only root filesystem for rootless backends - #71

Draft
jnfrati wants to merge 2 commits into
mainfrom
jnfrati/rootless-readonly-rootfs
Draft

jnfrati wants to merge 2 commits into
mainfrom
jnfrati/rootless-readonly-rootfs

Conversation

@jnfrati

@jnfrati jnfrati commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Platform-team finding #15. With rootless: true, the management, signal and relay containers now run with readOnlyRootFilesystem: true.

Change

  • netbird.securityContext: adds a backendContainer kind. It renders the container rootless defaults plus readOnlyRootFilesystem: true. Like container, it skips the OpenShift UID stripping, which only applies to pod contexts. The management, signal and relay deployments use it.
  • Management /tmp: when rootless is on, management gets an emptyDir on /tmp for the geolocation download. With rootless off, nothing changes.
  • Override: container.securityContext.readOnlyRootFilesystem: null removes the default, the same as for every other rootless key.
  • Docs and tests: values.yaml comments and the "Pod security" section of docs/configuration.md. tests/render.sh checks that the default render has neither the flag nor /tmp, that the rootless example has 3 read-only containers and exactly one /tmp mount, and that the null override works.

What each backend writes (0.82.0)

Checked in the source (filesystem calls in management, signal, relay, shared, encryption and util, v0.77.0 vs v0.82.0: the same set, with only refactors in util/file.go). Also checked with docker run --read-only --user 65532:65532 --cap-drop ALL --security-opt no-new-privileges, and docker diff on a writable run. This covered netbirdio/{management,signal,relay}:0.82.0 and the netbird-ee ghcr.io/netbirdio/{management,signal}-cloud:0.82.0-enterprise.1 images:

  • management: writes only to its data directory (stores, idp.db, geolocation databases) and to os.TempDir(). The GeoLite download unpacks into os.MkdirTemp("/tmp", "geolite*"). On first start /tmp peaks at about 460 MB and is emptied once the databases reach the data directory. EnsureEncryptionKey writes the config file only when dataStoreEncryptionKey is empty, and the chart always sets one.
  • signal and relay (relay with STUN on): nothing. Both stayed up under --read-only with no errors.
  • Dashboard: unchanged and still writable. Its image rewrites the nginx config and html at start-up.

Caveats

  • Custom log file or Let's Encrypt directory: if --log-file or the signal/relay Let's Encrypt data directory points at a path, that path needs a volume through volumes/volumeMounts. The other option is to set readOnlyRootFilesystem: null.
  • Ephemeral storage: the /tmp emptyDir has no sizeLimit, and the geolocation download briefly uses about 460 MB of it. A management ephemeral-storage limit below that gets the pod evicted on first start.
  • Dashboard: the dashboard is not read-only until the image stops rewriting files at start-up.

Compatibility

The default render (rootless: false) is unchanged. Rootless installs gain readOnlyRootFilesystem: true on the three backends and a /tmp emptyDir on management. No chart version bump.

Tested

On this branch, merged with current main (0.82.0, #69 and #70):

  • charts/netbird/tests/render.sh: pass.
  • helm lint --strict charts/netbird --values charts/netbird/tests/values/secret-refs.yaml: pass.
  • charts/netbird-ee/tests/render.sh: pass. netbird-ee with rootless on for every component renders 3 read-only backends and /tmp on management, and passes a server-side dry run. The NETBIRD_ENCRYPTION_KEY ... is a table warning also appears on main.
  • Example renders: every examples/*/values.yaml renders. examples/rootless is an overlay, so it renders together with the required secrets.
  • NB_E2E_ROOTLESS=true task chart:e2e (Kind, namespace enforcing restricted, backends 0.74.0 upgraded to 0.82.0): PASS in 458.5s. It covered the dashboard, API and IdP through the ingress, a direct connection, an upgrade that keeps the peers, a relayed connection, and management keeping its peers across a restart.
  • Plain helm template without values fails because the relay auth secret is required. This also happens on main and is not changed here.

Platform-team finding #15. Under rootless, management, signal and relay
containers now set readOnlyRootFilesystem: true through a new
backendContainer kind in netbird.securityContext. Like container, it is
exempt from the OpenShift UID stripping, which applies to pod contexts.

What each backend writes with chart defaults:
- management: its data directory (already a PVC or emptyDir) and
  os.TempDir() for the geolocation download (os.MkdirTemp), so rootless
  management gets an emptyDir on /tmp.
- signal and relay: nothing. A log file or Let's Encrypt data directory
  set to a path needs a volume through volumes/volumeMounts.

The dashboard stays writable: its image rewrites the nginx config and
html at start-up. Setting container.securityContext.readOnlyRootFilesystem
to null removes the default, as for every other rootless key.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant