All jobs

Add Pod and Container Security Contexts to a Helm Chart

Yes. An agent adds non-root, no-privilege-escalation and read-only root settings to your chart's values and templates, lints and renders it, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the chart repository and reads the chart as a reviewer would. In a repository like helm/examples, charts/hello-world/Chart.yaml is an application chart at version 0.1.0 with appVersion: "1.16.0", values.yaml sets image.repository: nginx with an empty tag, one replica and a ClusterIP service on port 80, and templates/deployment.yaml renders a Deployment with containerPort: 80 and HTTP liveness and readiness probes on /. There is no podSecurityContext, no securityContext on the container and no seccompProfile anywhere; templates/serviceaccount.yaml creates a ServiceAccount with no automountServiceAccountToken setting. ct.yaml points chart-testing at charts/, and .github/workflows/lint-test.yaml runs ct lint on every pull request and ct install on a kind cluster when a chart changed.

It then adds the settings in the two places a chart user expects them. values.yaml gains a podSecurityContext block with runAsNonRoot: true, runAsUser and runAsGroup set to the image's unprivileged user, fsGroup to match and seccompProfile.type: RuntimeDefault, and a container securityContext with allowPrivilegeEscalation: false, readOnlyRootFilesystem: true and capabilities.drop: [ALL]. deployment.yaml renders both with toYaml | nindent so a chart user can override any field. The stock nginx image cannot satisfy those settings, because its master process starts as root, binds port 80 and writes under /var/cache/nginx and /var/run, so the agent switches the default to the nginxinc/nginx-unprivileged image, which listens on 8080 as the nginx user, makes the container port a value, adds emptyDir volumes for the cache and PID paths the read-only root now blocks, and points the probes at the new port. The ServiceAccount gets automountServiceAccountToken: false since nothing in the chart calls the API.

Each decision is written where a reviewer will look for it: a comment above each new values key, a line in charts/hello-world/README.md listing the defaults and how to relax them for an image that needs root, and a bump of Chart.yaml to version 0.2.0, because a changed default image is not a patch. The agent checks that the unprivileged image publishes a tag matching the chart's appVersion before pinning it, and if it does not it says so in the pull request instead of inventing one.

It proves the chart still renders and lints without a cluster. It runs helm lint charts/hello-world, helm template with the default values and again with readOnlyRootFilesystem overridden to false, and pipes both renders through kubeconform -strict. It then runs the repository's own ct lint --config ct.yaml, the same command the workflow runs, so the pull request shows the chart passing the check the project already trusts.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Harden the Helm chart in this repository with pod and container security contexts. Read Chart.yaml, values.yaml, every template and the CI workflow first. Add a podSecurityContext (non-root user and group, fsGroup, RuntimeDefault seccomp) and a container securityContext (no privilege escalation, read-only root filesystem, all capabilities dropped) as overridable values rendered in the Deployment, set automountServiceAccountToken to false on the ServiceAccount, and switch the default image to one that runs as non-root if the current one cannot, adjusting the container port, probes and any writable paths it needs. Bump the chart version and document the new values in the chart README. Run helm lint, helm template with defaults and with the read-only root disabled, kubeconform on both renders, and ct lint with the repository's ct.yaml, then open a pull request with the settings table and the command output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that changes values.yaml, templates/deployment.yaml, templates/serviceaccount.yaml, Chart.yaml and the chart README, with a table in the description of every security setting, its default and the values key that overrides it, and a separate paragraph on the image change and why the stock image could not run under the new settings.

The run's record keeps the helm lint, both helm template renders, the kubeconform -strict passes and the ct lint output, so a reviewer can read the rendered Deployment with the contexts in place rather than reasoning about the template.

Before merging, a reviewer installs the chart on a development cluster, confirms the pod starts and the probes pass on the new port, and decides whether any environment still needs the old root image through a values override.

Run it on every Linear issue labelled hardening

An automation in the chart repository's Project with a linear trigger on linear.issue.labeled and the label hardening starts one run per labelled issue, with the issue added after the prompt. An issue that names the chart to harden or the image to prefer narrows the run; one with no detail gets the full read of the chart first. Changes made by an app integration never fire it, so the pull request's own link on the issue starts nothing.

A run whose helm lint or ct lint fails ends needs_review with the output in its record instead of opening a pull request that cannot pass the repository's own workflow, and the automation's max_runs_per_hour cap keeps a batch of labelled issues to a pace the team can review.

The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.

Why run it on Rush?

A security context is a small diff with a large blast radius: one wrong user id or one writable path missed and the pod never starts. The agent reads the image's requirements, chooses an image that can run as non-root, adds the writable paths the read-only root takes away, and renders and lints the chart in its own sandbox before anyone reviews it.

Rush keeps every command and its output in the run's record, so the reviewer sees the rendered manifests and the lint results rather than a description that says the chart works. And because the request is the same for every chart a team publishes, the hardening lands in each repository with its own render and its own table.

Frequently asked questions

Why change the default image?

Because runAsNonRoot and a read-only root filesystem cannot be satisfied by an image whose entrypoint starts as root and binds port 80. The unprivileged nginx image is the maintained variant for exactly this case. If your chart's image already runs as a non-root user, the agent keeps it and sets the user id to match.

Can I turn one setting off for one environment?

Yes. Every setting is a value rendered with toYaml, so a values file for that environment can set securityContext.readOnlyRootFilesystem: false or drop the seccomp profile without editing the template. The chart README lists each key.

Does it run the chart on a cluster?

No. The run lints, renders and validates the chart against Kubernetes schemas with kubeconform. The ct install step on kind that the repository's workflow runs happens in CI on the pull request, and a reviewer's install on a development cluster is the final check.

Why bump the minor version instead of the patch?

A different default image and a different container port change what a chart user gets on upgrade. The agent treats that as a feature-level change, bumps the minor version and says so in the README, so anyone pinning the old version is not surprised.

More Helm jobs

The same job on other stacks

More jobs like this: Turn a Linear label into a PR

Keep reading