# Add a Pod Disruption Budget to a Helm Chart

Yes. An agent adds an opt-in PodDisruptionBudget template to your Helm chart as sibling charts do, bumps the chart version, lints and renders it, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-pod-disruption-budgets/helm/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the chart and its neighbours before it adds a template. In a repository like prometheus-community/helm-charts, the `prometheus-redis-exporter` chart at `charts/prometheus-redis-exporter` is at `version: 6.35.0` with `appVersion: v1.95.0`, and its `templates/` directory holds `deployment.yaml`, `service.yaml`, `serviceaccount.yaml`, `servicemonitor.yaml`, `prometheusrule.yaml`, `networkpolicy.yaml`, `role.yaml`, `rolebinding.yaml`, `extra-manifests.yaml`, `NOTES.txt` and `_helpers.tpl`, with no disruption budget. `values.yaml` sets `replicaCount: 1`, and `deployment.yaml` takes `replicas` from it and its pod selector from the `prometheus-redis-exporter.selectorLabels` helper. The chart's `README.md` documents its values, and `ci/extramanifests-values.yaml` is the one extra values file chart-testing installs with.

The same repository already has the pattern it wants. `charts/prometheus-blackbox-exporter/templates/poddisruptionbudget.yaml` is wrapped in `{{- if .Values.podDisruptionBudget -}}`, emits `policy/v1` `PodDisruptionBudget` named with the chart's `fullname` helper, labelled with its `labels` helper, selects on its `selectorLabels` helper, and copies whatever the `podDisruptionBudget` value holds into `spec` with `toYaml`, so a user sets `maxUnavailable` or `minAvailable` and nothing else is invented. Its `values.yaml` has `podDisruptionBudget: {}` with a commented `maxUnavailable: 0`. The repository's `CONTRIBUTING.md` requires a semver version bump for any chart change, and `.github/workflows/ci.yaml` runs `ct lint` with `.github/linters/ct.yaml`, fails when more than one chart changes in a pull request, and installs each changed chart on a cluster once per values file under its `ci/` directory, with `helm unittest --strict` as an additional command for charts that have a `unittests/` directory.

The agent copies that pattern into `charts/prometheus-redis-exporter/templates/poddisruptionbudget.yaml`, using this chart's own `fullname`, `labels` and `selectorLabels` helpers from `_helpers.tpl`, adds `podDisruptionBudget: {}` to `values.yaml` with the same commented example, and documents the value in the chart's `README.md` table. It bumps `Chart.yaml` from `6.35.0` to `6.36.0`, a minor bump for a new optional feature, and adds `ci/pdb-values.yaml` setting `replicaCount: 2` and `podDisruptionBudget.maxUnavailable: 1`, so chart-testing installs and tests the new template on every pull request from now on. It adds `unittests/poddisruptionbudget_test.yaml` with two cases, one asserting no document renders by default and one asserting the `maxUnavailable` and selector when the value is set, because `ct.yaml` runs the plugin on any chart that has the directory. It touches no other chart, since `ci.yaml` would fail the pull request otherwise.

Before pushing, the agent runs `helm lint` on the chart, `helm template` with the default values to show no budget renders, `helm template -f ci/pdb-values.yaml` to show the rendered `PodDisruptionBudget` with the right selector, `helm unittest --strict` with the new test file, and `ct lint --config .github/linters/ct.yaml` against the branch, which also validates the version bump and the README. It opens the pull request with those outputs and a note that a budget with `replicaCount: 1` and `maxUnavailable: 0` would block node drains, which is why the default stays empty.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add an opt-in PodDisruptionBudget to the prometheus-redis-exporter chart in this Helm charts repository and open a pull request. Read charts/prometheus-redis-exporter/Chart.yaml, values.yaml, README.md, templates/deployment.yaml, templates/_helpers.tpl and ci/, then read charts/prometheus-blackbox-exporter/templates/poddisruptionbudget.yaml and its values, CONTRIBUTING.md, .github/workflows/ci.yaml and .github/linters/ct.yaml first. Write templates/poddisruptionbudget.yaml following the blackbox exporter pattern with this chart's own helpers, gated on a podDisruptionBudget value that defaults to an empty map, and copy the value into spec with toYaml. Document the value in the chart README, bump the chart version by a minor step, add a ci values file with two replicas and maxUnavailable 1, and add a helm-unittest file covering the default and the enabled case. Change no other chart. Run helm lint, helm template with and without the ci values, helm unittest --strict and ct lint, and quote the outputs in the pull request.",
  "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 on its own branch touching one chart: a new `templates/poddisruptionbudget.yaml`, a `podDisruptionBudget: {}` entry in `values.yaml`, a row in `README.md`, `Chart.yaml` at `6.36.0`, a new `ci/pdb-values.yaml` and a new `unittests/poddisruptionbudget_test.yaml`. The description explains the opt-in default, shows the rendered budget from the ci values, and points at the blackbox exporter template as the pattern it followed.

The proof is the sandbox output quoted in the description and kept in the run's record: `helm lint` clean, the two `helm template` runs, `helm unittest --strict` passing both cases, and `ct lint` accepting the version bump. The repository's own `ci.yaml` runs on the pull request too, installing the chart with the default values and with `ci/pdb-values.yaml`, which is the first time the budget is created on a real cluster.

Before merging, a reviewer checks that the selector in the rendered budget matches the Deployment's selector exactly, that the README row matches the house format, that the version bump is the right size for the chart's release notes, and that the example in `values.yaml` does not suggest `maxUnavailable: 0` for a single replica. Then they approve and let the release workflow publish the chart.

## Run it on every chart with a Deployment and no budget

A team that maintains many charts sends one `POST /o/{org}/sessions` per chart, with this prompt naming the chart directory and the repository in `resources`. Because this repository's CI fails a pull request that changes more than one chart, one run per chart is the right shape: a script can list `charts/*/templates`, grep each for `PodDisruptionBudget`, and start a run for every chart with a `Deployment` and no budget. Each run bumps its own chart's version and opens its own pull request.

Set a webhook URL on the API key and Rush POSTs `run.completed` or `run.failed` when a run's turn finishes, with `session_url` so your server can collect the pull request links. Send a fresh UUID as `request_id` with each request so a retry returns the run already started.

## Why run it on Rush?

A disruption budget is ten lines of template and a dozen rules about everything around it: the helper names, the version bump, the README table, the one-chart-per-pull-request rule, the values file chart-testing picks up, the unit test plugin. On Rush the agent reads those rules from the repository's own CI config and sibling charts, then runs the same `helm lint`, `helm template`, `helm unittest` and `ct lint` in its own sandbox before pushing, so the pull request arrives already shaped the way the maintainers' CI expects.

Every command and rendered manifest stay in the run's record, the diff is confined to one chart, and nothing publishes until a person merges and the release workflow runs. The same request can go to every chart in the repository that lacks a budget, one sandbox and one pull request each, without a maintainer copying a template forty times.

## Frequently asked questions

### Why is the budget off by default?

Because the chart ships `replicaCount: 1`, and a budget with `maxUnavailable: 0` on a single replica would block every node drain. Following the blackbox exporter chart, `podDisruptionBudget` defaults to an empty map, the template renders nothing, and a user who runs two or more replicas opts in by setting `maxUnavailable` or `minAvailable`.

### Why copy the value with toYaml instead of fixed fields?

It is the pattern the repository already uses, and it lets a user set either `minAvailable` or `maxUnavailable`, as a number or a percentage, plus `unhealthyPodEvictionPolicy` on newer clusters, without the chart needing a release for each field. The unit test pins the shape so a typo in the value fails fast.

### Does it change other charts that lack a budget?

No. The repository's `ci.yaml` fails a pull request that changes more than one chart, so the agent changes exactly one. Start one run per chart to cover the others; each run bumps that chart's own version.

### Which version bump does it make?

A minor one, `6.35.0` to `6.36.0`, because an optional new template is a backwards-compatible feature under the semver rules in `CONTRIBUTING.md`. If your chart tracks another convention, say so in the prompt and the agent follows it.

## More Helm jobs

- [Add Resource Requests and Limits to a Helm Chart](https://getrush.ai/run/add-resource-limits/helm/)
- [Add Pod and Container Security Contexts to a Helm Chart](https://getrush.ai/run/add-security-context/helm/)
- [Add a ServiceMonitor to a Helm Chart](https://getrush.ai/run/add-service-monitors/helm/)

## The same job on other stacks

- [Add Pod Disruption Budgets to Kubernetes Manifests from a Linear Issue](https://getrush.ai/run/add-pod-disruption-budgets/kubernetes/)
- [Add Pod Disruption Budgets to a Kustomize App](https://getrush.ai/run/add-pod-disruption-budgets/kustomize/)
- [Add Pod Disruption Budgets to Argo CD Applications](https://getrush.ai/run/add-pod-disruption-budgets/argo-cd/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
