# Add Pod Disruption Budgets to a Kustomize App

Yes. An agent adds a PodDisruptionBudget per stateless Deployment in your Kustomize base, raises replicas where a budget needs them, renders it and opens a PR.

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

## What the agent does

The agent reads the base before it writes a budget, because a budget on a one-replica Deployment blocks every node drain. In a Kustomize app like the `sock-shop` directory of argoproj/argocd-example-apps, `kustomization.yaml` lists twenty-nine resources under `base/`: fourteen Deployments, their fourteen Services and one Ingress. Every Deployment has `replicas: 1` and selects on a single `name:` label, there is no `strategy:` anywhere, and the files split cleanly into two groups. Eight application services (`front-end`, `carts`, `catalogue`, `orders`, `payment`, `shipping`, `user` and `queue-master`) carry `livenessProbe` and `readinessProbe` on an HTTP path and resource requests and limits, and all but `queue-master` a read-only root filesystem. The six backing stores (`carts-db`, `orders-db`, `user-db`, `catalogue-db`, `session-db` and `rabbitmq`) are single containers, two plain `mongo` images, `redis:alpine`, `rabbitmq:3.6.8-management` and the demo's own `catalogue-db` and `user-db` images, with no probes and no persistent volume.

It then adds budgets only where they are safe. For each of the eight stateless services the agent writes a `policy/v1` `PodDisruptionBudget` whose selector matches the Deployment's own `matchLabels` (`name: front-end` and so on) with `maxUnavailable: 1`, and raises that Deployment to `replicas: 2` in the same change, because a budget that permits one unavailable pod on a single replica still lets a drain evict the only pod. The budgets go into new `base/<service>-pdb.yaml` files, one per service, and `kustomization.yaml` lists each beside its Deployment and Service so the directory keeps its one-resource-per-file shape.

The six single-container stores get no budget, and the pull request says why: with one replica and no volume, a budget of `minAvailable: 1` would make the pod unevictable and stall cluster upgrades, while `maxUnavailable: 1` would be a no-op. The agent also leaves `replicas: 1` on them, since running two copies of a Mongo container with no replication would not make the data any safer. Where a store is a candidate for a StatefulSet later, the description notes it, but that is a different change.

The proof is a render and a dry run. The agent runs `kustomize build sock-shop` and shows the eight new `PodDisruptionBudget` objects and the eight changed `replicas` values in the output, then `kubeconform` over the rendered stream to validate the `policy/v1` schema, and for each budget checks with a script that its selector equals the `matchLabels` of exactly one Deployment in the same render. Because the repository is deployed by an Argo CD Application whose `syncPolicy` in `apps/templates/applications.yaml` has `automated` with `prune` and `selfHeal`, the agent calls out in the pull request that merging will roll the eight Deployments to two replicas on the next sync.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add PodDisruptionBudgets to the Kustomize app under sock-shop in this repository. Read sock-shop/kustomization.yaml and every file under sock-shop/base first, and sort the Deployments into stateless services with probes and single-container data stores. For each stateless service add a policy/v1 PodDisruptionBudget in its own base/<name>-pdb.yaml with maxUnavailable 1 and a selector equal to the Deployment's matchLabels, raise that Deployment to 2 replicas, and list the new file in kustomization.yaml next to the Deployment. Add no budget to the data stores and explain why in the pull request. Run kustomize build, validate the render with kubeconform, check that each budget's selector matches exactly one Deployment, and open a pull request that notes what the next Argo CD sync will change.",
  "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 with eight new files under `sock-shop/base/`, one `PodDisruptionBudget` each for `front-end`, `carts`, `catalogue`, `orders`, `payment`, `shipping`, `user` and `queue-master`, a one-line `replicas` change in each of those eight Deployments, and eight new entries in `sock-shop/kustomization.yaml`. The six data-store Deployments, every Service and the Ingress are untouched.

The description holds the rendered budgets from `kustomize build`, the `kubeconform` summary, a table pairing each budget's selector with the Deployment it matches, and a short section on the data stores it skipped and why. It also says plainly that an Argo CD Application with automated sync will scale the eight services to two replicas when the change lands. The transcript at `GET /o/{org}/sessions/{id}/messages` keeps every command and its output.

Before merging, a reviewer checks that the cluster has room for eight more pods at the requests those Deployments declare, decides whether `front-end` should get `minAvailable: 1` instead, and whether any store should become a StatefulSet first. A follow-up message to the same session can add a `topologySpreadConstraints` block so the two replicas land on different nodes, which is what makes a budget worth having.

## Run it on every Linear issue labelled platform

A platform team that tracks reliability work in Linear starts one run per issue from an automation with a `linear` trigger on the `platform` label, in the Project that holds the manifests repository. The automation adds the issue after this prompt, so an issue that names the services to cover, or asks for `minAvailable` on the front end, is what the agent reads.

Each run renders in its own sandbox and opens its own pull request that links the issue, and an automation run has its own `max_runs_per_hour` cap. The rendered output in the description means a reviewer judges the change without running Kustomize locally.

## Why run it on Rush?

Disruption budgets are easy to write and easy to get wrong: a selector that matches nothing protects nothing, a budget on a single replica blocks drains, and a repository synced by Argo CD applies the mistake automatically. The agent reads every Deployment first, adds budgets only where replicas can be raised safely, and proves the render and the selectors in a sandbox with its own copies of `kustomize` and `kubeconform`.

The pull request carries the render, the validation and the selector table, so the review is a read of eight small files and one list. Several apps in the same repository, or several repositories, can be handled at once, each in its own sandbox with its own pull request.

## Frequently asked questions

### Why raise replicas as part of this change?

Because every Deployment in the base runs one replica, and a budget cannot make one pod highly available. With `maxUnavailable: 1` and two replicas, a node drain evicts one pod while the other keeps serving. The pull request pairs each budget with its replica change so neither lands without the other.

### Why do the databases get no budget?

They are single containers with no replication and no persistent volume. A `minAvailable: 1` budget on one of them would make that pod unevictable and stall node upgrades, and `maxUnavailable: 1` would change nothing. The description lists them and suggests a StatefulSet as the real fix.

### Will the Argo CD sync apply this straight away?

If your Application has `automated` sync with `selfHeal`, as the `apps` chart in the example repository does, yes: the next sync creates the budgets and scales the eight Deployments. The pull request says so, and a reviewer can merge at a quiet time or disable auto-sync for that one Application first.

### What proves the selectors are right?

A script over the `kustomize build` output that, for each budget, finds the Deployments whose `matchLabels` equal the budget's selector and requires exactly one. Its result is a table in the pull request, so a selector typo would show up as a zero before anyone merges.

## More Kustomize jobs

- [Add Resource Requests and Limits to a Kustomize App from a Linear Issue](https://getrush.ai/run/add-resource-limits/kustomize/)
- [Add Pod and Container Security Contexts to Kustomize Manifests](https://getrush.ai/run/add-security-context/kustomize/)
- [Add Prometheus ServiceMonitors to a Kustomize App](https://getrush.ai/run/add-service-monitors/kustomize/)

## The same job on other stacks

- [Add Pod Disruption Budgets to Argo CD Applications](https://getrush.ai/run/add-pod-disruption-budgets/argo-cd/)
- [Add Pod Disruption Budgets to a GKE App](https://getrush.ai/run/add-pod-disruption-budgets/gke/)
- [Add a Pod Disruption Budget to a Helm Chart](https://getrush.ai/run/add-pod-disruption-budgets/helm/)

## 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/)
