Skip to content

sourcegraph: read-only root filesystem for blobstore, cadvisor, otel, and pgsql-exporter - #1003

Draft
marcleblanc2 wants to merge 1 commit into
mainfrom
marc/read-only-root-filesystem-remaining-workloads
Draft

marcleblanc2 wants to merge 1 commit into
mainfrom
marc/read-only-root-filesystem-remaining-workloads

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Open issues

Found in review on 2026-11-13 (review thread), at a6fa5d5. The change passed its cluster test (see "Test plan"); this PR is a draft until the first is fixed.

  1. Conflicts with main in README.md. Fix: rebase and regenerate it with ./scripts/helm-docs.sh
  2. A release that already mounts its own volume at /tmp on blobstore collides with the new tmpdir volume. The API rejects a new Deployment with two mounts at /tmp (mountPath: must be unique), or with a second volume named tmpdir. Checked with kubectl create --dry-run=server; a real helm upgrade of such a release was not run. Fix: say so in the changelog
  3. No test asserts the new defaults or the tmpdir volume
  4. Small ones:
    • the changelog does not name the keys that revert otel-agent, otel-collector, and the exporter sidecar (openTelemetry.agent, openTelemetry.gateway, postgresExporter)
    • "every container except prometheus" leaves out the helm test pod, which sets no security context

Problem

Some customers need a read-only root filesystem on every container

These containers didn't set readOnlyRootFilesystem: true:

  • blobstore, cadvisor, otel-agent, and otel-collector
  • The pgsql-exporter sidecar of pgsql, codeintel-db, and codeinsights-db
    • The templates read postgresExporter.containerSecurityContext, but values.yaml never defined it

Solution

Set readOnlyRootFilesystem: true on each of them:

  • blobstore also gets an emptyDir at /tmp
  • cadvisor stays privileged
  • values.yaml defines postgresExporter.containerSecurityContext, which also sets allowPrivilegeEscalation: false
    • It sets no runAsUser or runAsGroup, so the sidecar keeps running as its database pod's user
  • No image change is needed

Not changed:

Test plan

  • helm lint charts/sourcegraph and helm unittest charts/sourcegraph pass
  • helm template with default values renders readOnlyRootFilesystem: true on every container except prometheus, and the tmpdir volume on blobstore

Helm

On the EKS test instance m5, on 2026-11-13, by upgrading from main to this branch merged onto main, with cadvisor.enabled: true:

  • All pods Ready. blobstore, otel-collector, the three databases, and each cadvisor and otel-agent pod were replaced once
  • Of the running containers, only prometheus and the k8s executor (a separate chart) lack a read-only root filesystem
  • No read-only or permission errors in the logs of the changed containers
  • blobstore: /tmp is writable, the rest of the root filesystem is not, and a search job completed and wrote its results to blobstore
  • The three exporter sidecars report pg_up 1 with no scrape errors, running as their database's user
  • Each cadvisor pod queried serves container metrics, and otel-agent and otel-collector start cleanly
  • Search works

Not run:

Docker Compose

Linked PRs

Amp threads

Changelog

  • blobstore, cadvisor, otel-agent, otel-collector, and the pgsql-exporter sidecars now run with a read-only root filesystem
    • Set <serviceName>.containerSecurityContext.readOnlyRootFilesystem: false to revert
  • Added postgresExporter.containerSecurityContext, which the templates already read but values.yaml did not define

… and pgsql-exporter

These were the only containers in the chart, besides prometheus, without
readOnlyRootFilesystem: true. blobstore gets an emptyDir at /tmp.

postgresExporter.containerSecurityContext was read by the three database
StatefulSets but never defined, so the sidecar rendered securityContext: null.
It sets no user, so the sidecar keeps running as its database pod's user.

Amp-Thread-ID: https://ampcode.com/threads/T-01a13cfb-9756-7111-8b29-381a841065e1
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

Copy link
Copy Markdown

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