What the agent does
The agent reads replicas, selectors and labels before it writes a budget. In a GKE app like the quickstarts/guestbook sample in GoogleCloudPlatform/kubernetes-engine-samples, frontend-deployment.yaml runs replicas: 3 of gb-frontend:v5 with a selector of app: guestbook, tier: frontend and requests of 100m CPU and 100Mi memory; redis-leader-deployment.yaml runs replicas: 1 of docker.io/redis:6.0.5 and redis-follower-deployment.yaml runs replicas: 2 of gb-redis-follower:v2. Both Redis Deployments select only app: redis while their pod templates carry role: leader or role: follower and tier: backend, and the Services in redis-leader-service.yaml and redis-follower-service.yaml select on all three labels. Elsewhere the repository already has two budgets to follow: quickstarts/hello-app-redis/manifests/pdb-minavailable.yaml with minAvailable: 3 and databases/gke-stateful-mysql/kubernetes/mysql-pdb-maxunavailable.yaml with maxUnavailable: 1, both policy/v1, one resource per file, under the Apache header and [START …]/[END …] region tags every manifest in the repository carries.
The agent writes one file per budget in the guestbook directory. frontend-pdb.yaml selects exactly the Deployment's selector, app: guestbook, tier: frontend, with maxUnavailable: 1, so a node drain can evict one of the three frontends at a time and the budget keeps working if the replica count changes later. redis-follower-pdb.yaml selects app: redis, role: follower with minAvailable: 1 as an integer: that selector is narrower than the Deployment's app: redis, and the Kubernetes documentation reserves maxUnavailable and percentages for a budget whose selector matches the owning workload exactly, so the integer form is the one that is defined for it. The leader gets no budget, and the description says why: with replicas: 1, any minAvailable: 1 would refuse every voluntary eviction, and GKE's surge upgrade respects a budget for up to one hour and then evicts the pod anyway, so the budget would only turn a quick restart into an hour-long stall.
Overlap is the trap with these labels. A budget on app: redis alone would cover both leader and follower pods, and the eviction API refuses to evict any pod covered by more than one budget, so the agent keeps the follower selector narrow and checks every pod template in the directory against every budget selector, confirming each pod matches at most one. It adds unhealthyPodEvictionPolicy: AlwaysAllow to the frontend budget so a pod that is Running but not yet Ready does not block a drain, and leaves the default IfHealthyBudget on the followers, where a half-started replica is the one the budget is meant to protect. The hello-app quickstart in the same repository shows the other case the description covers: its helloweb Deployment has an HPA from minReplicas: 1 to maxReplicas: 5, where maxUnavailable: 1 works at every scale and minAvailable: 1 would block drains whenever the autoscaler is at one.
Without a cluster, the checks are offline. The agent runs kubeconform -strict over the new files with the policy/v1 schema and kubectl apply --dry-run=client to catch a field in the wrong place, and writes a short script that extracts each Deployment's template labels and each budget's matchLabels and prints which budget, if any, covers each workload, so the one-budget-per-pod rule is shown rather than asserted. The README for the sample gets a paragraph on kubectl get pdb, whose ALLOWED DISRUPTIONS column is how a reader confirms the budgets on a live cluster, and on what GKE does with a budget during a node pool upgrade.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add PodDisruptionBudgets to the guestbook app in this repository. Read every file under quickstarts/guestbook/, the existing budgets under quickstarts/hello-app-redis/manifests/ and databases/gke-stateful-mysql/kubernetes/, and quickstarts/hello-app/manifests/helloweb-hpa.yaml first. Write one policy/v1 budget per file in the repository's style with its license header and region tags: maxUnavailable 1 for the frontend selecting exactly the Deployment's selector with unhealthyPodEvictionPolicy AlwaysAllow, and an integer minAvailable 1 for the Redis followers selecting app redis and role follower. Do not write a budget for the single-replica leader and explain why in the PR, including GKE's one-hour limit on respecting a budget during surge upgrades. Check that no pod template is matched by more than one budget and show the check. Validate with kubeconform and kubectl apply --dry-run=client, include the output, add a README paragraph on kubectl get pdb and node upgrades, and open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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 adds quickstarts/guestbook/frontend-pdb.yaml and quickstarts/guestbook/redis-follower-pdb.yaml and a paragraph to quickstarts/guestbook/README.md. The Deployments and Services are unchanged; no selector is edited to make a budget fit.
The description holds a table of workload, replicas, selector, budget and policy, the sentence on why the leader has none, and the kubeconform, dry-run and overlap-check output. The commands and their full output are in the transcript at GET /o/{org}/sessions/{id}/messages.
Before merging, a reviewer applies the files to a staging cluster and reads kubectl get pdb to see ALLOWED DISRUPTIONS of 1 for the frontend and 1 for the followers, then drains a node to watch the eviction order. A follow-up message to the same session can convert the files to a Kustomize base, add budgets for the other quickstarts, or switch the frontend to a percentage once the replica count is large enough for one to matter.
Run it on every GKE workload a node upgrade can take down
A platform team with several application repositories sends one POST /o/{org}/sessions per repository with this prompt as input and the repository in resources. Each run reads its own manifests, so a repository that deploys with Helm gets the budget as a template with replicaCount in its condition, and one with StatefulSets gets maxUnavailable where the selector allows it.
Send a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run it already started. The key's webhook_url reports when each run the key starts finishes, with session_url for the pull request link and the validation output.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A disruption budget is a few lines, and the wrong few lines either do nothing or freeze node upgrades: a selector that overlaps another budget makes every eviction fail, a minAvailable equal to the replica count blocks drains, and a percentage on a two-replica workload rounds up to all of it. The agent reads each Deployment's selector and replica count, follows the budgets the repository already has, and proves the selectors do not overlap in a sandbox of its own, with the output kept.
The pull request carries the budgets, the overlap check and the reasoning about the single-replica leader, so a reviewer reads one diff rather than discovering a stuck upgrade in the GKE console. Several repositories can be done at once, each in its own sandbox with its own pull request.
Frequently asked questions
Why no budget for the Redis leader?
It has one replica. minAvailable: 1 would refuse every voluntary eviction, and GKE's surge upgrade respects a budget for up to one hour before evicting the pod anyway, so the budget buys an hour of delay and no safety. The fix for the leader is a second replica or a managed Redis, which the pull request names as a separate decision.
minAvailable or maxUnavailable?
maxUnavailable when the budget's selector matches the Deployment exactly, because it keeps working as replicas change. The follower selector is narrower than its Deployment's app: redis, so the agent uses an integer minAvailable, the form the Kubernetes documentation defines for a selector that is a subset of the workload's.
Will this block GKE node upgrades?
It slows them to one frontend and one follower at a time, which is the point. GKE honours a budget during a surge upgrade for up to one hour and then force-evicts, and a blue-green upgrade removes whatever is still running when it deletes the old nodes, which does not respect budgets, so a budget never makes an upgrade impossible.
Does this work on Autopilot?
Yes. Budgets are a Kubernetes API, and Autopilot clusters use surge upgrades, so the same one-hour behaviour applies. The files do not depend on node pools or any GKE-specific field.
Does a budget protect against a node failure?
No. It governs voluntary disruptions, evictions from drains, upgrades and the cluster autoscaler. A node that dies takes its pods with it regardless, which is why the replica counts and the anti-affinity a reviewer may add next matter as much as the budget.