All jobs

Add a NetworkPolicy Option to a Helm Chart

An agent finds a chart's networkPolicy.enabled already exists, adds allowedSources to limit ingress, and passes helm lint, ct lint and 6 unit tests.

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

What the agent does

Before writing, the agent reads templates/networkpolicy.yaml, the networkPolicy block of values.yaml, ci/networkpolicy-values.yaml and .github/linters/ct.yaml for prometheus-blackbox-exporter. networkPolicy.enabled was already there, with allowMonitoringNamespace and monitoringNamespaceName. With enabled alone the policy rendered ingress: [{}], which allows everything.

So it adds networkPolicy.allowedSources, a list of NetworkPolicy peers (podSelector, namespaceSelector, ipBlock). When it or allowMonitoringNamespace is set, the template renders one from with those peers, on service.port only. It adds ci/networkpolicy-sources-values.yaml, six cases in unittests/networkpolicy_test.yaml (the chart had no unit tests), and bumps the chart from 11.20.3 to 11.21.0.

Start it with one API call

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

{
  "agent": "claude",
  "input": "A Linear issue labeled agent says: \"Add a NetworkPolicy Option to a Helm Chart. Add networkPolicy.enabled to the prometheus-blackbox-exporter chart, rendering a NetworkPolicy that allows only the configured ingress sources, with unit tests and a chart version bump.\" Do the work in this repository, add tests for it, run helm lint, ct lint and helm unittest, and open a pull request that links back to the issue.",
  "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

Tried on prometheus-community/helm-charts at e45a7844: 5 files changed, 103 insertions(+), 2 deletions(-). helm lint printed 1 chart(s) linted, 0 chart(s) failed before and after, and helm unittest went from Tests: 0 passed, 0 total to Tests: 6 passed, 6 total. ct lint with the repository's config exited 1 on the untouched clone, unable to find chart_schema.yaml; given the schema and lint config from the ct release, it ended All charts linted successfully before and after.

For the reviewer: the issue asked to add networkPolicy.enabled, but it existed and defaults to allow-all. The run extended it rather than make enabled deny by default, which would break current installs. Nothing was installed to a cluster, so the tests prove the rendered YAML, not enforcement.

Run it on every Linear issue labeled agent

An automation with a linear trigger on linear.issue.labeled and the label agent runs the linear-label-to-pr recipe's prompt when someone in your Rush org labels a chart issue. This one asked for an option that already existed and allowed all ingress; an issue that says whether enabled alone should deny traffic decides what this run left to a reviewer.

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

Why run it on Rush?

The request named a value the chart already had. The run read the template before writing, kept the allow-all default that existing installs depend on, and added the narrower option instead. It also found that the repository's own ct lint config fails in a fresh sandbox, and ran lint with the release's schema files rather than skip it.

Frequently asked questions

Does turning on networkPolicy.enabled now block traffic?

Not by itself. With no allowedSources and allowMonitoringNamespace off, the policy still renders ingress: [{}], as before, which is why a minor bump to 11.21.0 is enough. One unit test checks exactly that.

Why helm-unittest v1.0.0?

The latest plugin refused to load under helm 3.17.3, the version the run installed, so it pinned v1.0.0. Upstream CI may supply the plugin and the ct schema files differently.

More Helm jobs

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

Keep reading