All jobs

Add Vertical Pod Autoscaler Recommendations to Kubernetes Deployments

Yes. An agent adds a VerticalPodAutoscaler per Deployment in recommendation-only mode with bounds taken from your manifests, validates the render 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 repository into its own cloud sandbox and reads every workload before writing an autoscaler for it. In a repository like GoogleCloudPlatform/microservices-demo, kubernetes-manifests/ holds one file per service with a Deployment, a Service and a ServiceAccount each, and a kustomization.yaml that lists them with loadgenerator.yaml commented out. Every container has fixed requests and limits, and they are not uniform: most services ask for 100m CPU and 64Mi memory with limits of 200m and 128Mi, adservice asks for 200m and 180Mi with limits of 300m and 300Mi, recommendationservice for 100m and 220Mi up to 450Mi, cartservice for 200m and 64Mi, and cartservice.yaml carries a second Deployment, redis-cart, with 70m and 200Mi. There is no HorizontalPodAutoscaler and no VerticalPodAutoscaler anywhere, including helm-chart/, kustomize/components/ and release/kubernetes-manifests.yaml. The kubernetes-manifests/README.md says these files are rendered through skaffold, and kustomize/ holds the deployable variant with optional components for Memorystore, Spanner, network policies and others.

It follows the repository's own pattern and adds a new component, kustomize/components/vertical-pod-autoscaler/, with a kustomization.yaml and one VerticalPodAutoscaler from autoscaling.k8s.io/v1 per Deployment: the eleven services and redis-cart, twelve objects, each with a targetRef naming its apps/v1 Deployment. Every one starts in updateMode: "Off", which makes the recommender compute target, lower-bound and upper-bound requests and write them to the object's status without ever evicting a pod or changing a request. That is the mode to begin with on a service whose requests were set by hand, because it turns the question from guesswork into a number a reviewer can read with kubectl describe vpa.

The bounds come from the manifests rather than from a template. For each container the agent sets minAllowed at the current request, so a recommendation can never suggest less than what the service runs with today, and maxAllowed at the current limit, so the recommendation stays inside the headroom the authors already accepted; controlledResources lists both cpu and memory. The agent writes the reasoning for the first service in a comment and refers to it from the others. Because the kustomize/components/ layout needs a line in kustomize/kustomization.yaml to enable a component, it adds that line commented out beside the existing optional components, so enabling the autoscalers is the same one-line change as enabling network policies, and adds a docs/ page explaining the modes, the prerequisite that the cluster has the VPA components installed, and how to read a recommendation.

It validates everything it can without a cluster. In the sandbox it installs kubectl and kubeconform, renders kubectl kustomize kustomize/ with the component enabled on a scratch copy of the kustomization, and runs kubeconform -strict over the output with the VPA custom resource schema supplied from the CRD catalog so the twelve objects are checked against the real autoscaling.k8s.io/v1 shape, not only for valid YAML. It also renders with the component disabled to show the default output is byte-for-byte unchanged, and runs the repository's existing kustomize-build-ci.yaml steps locally. The output goes into the pull request description.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Add Vertical Pod Autoscaler objects to this Kubernetes repository in recommendation-only mode. Read kubernetes-manifests, kustomize and its components, helm-chart/values.yaml and release/kubernetes-manifests.yaml first, list every Deployment with its current requests and limits, and confirm whether any horizontal or vertical autoscaler already exists. Add a kustomize component with one VerticalPodAutoscaler per Deployment, including any secondary Deployment that shares a file, with updateMode Off, minAllowed equal to the current requests, maxAllowed equal to the current limits and both cpu and memory controlled, and a comment explaining the bounds. Add a commented-out line enabling the component beside the existing optional components, and a docs page on the modes, the cluster prerequisite and how to read recommendations. Do not change any Deployment. In your sandbox render the kustomization with and without the component, validate the rendered output with kubeconform using the VPA CRD schema, and open a pull request with the Deployment 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 adding kustomize/components/vertical-pod-autoscaler/ with its kustomization.yaml and twelve VerticalPodAutoscaler objects, one commented-out line in kustomize/kustomization.yaml, and a page under docs/. No Deployment, Service or resource value changes. The description has a table of every Deployment with its current requests and limits and the bounds the autoscaler received, so a reviewer can check each pair against the manifest without opening it.

The run's record keeps the kubectl kustomize render with and without the component, the kubeconform validation against the VPA schema, and the diff showing the default render unchanged, which is how a reviewer knows the component is inert until enabled and well-formed when it is.

Before merging, a reviewer confirms the VPA recommender runs in the target cluster, decides whether loadgenerator, which is disabled in the manifests list, should get an autoscaler at all, and agrees on a date to read the recommendations and open the follow-up that adjusts requests or moves a service to Initial mode.

Run it on every Linear issue labelled capacity

A platform team that tracks right-sizing work in Linear starts one run per issue from an automation with a linear trigger on the capacity label, in the Project that holds the manifests. The trigger adds the issue after this prompt, so an issue that names one namespace, asks for Initial mode on a stateless service, or asks for the recommendations collected after a week to be turned into new requests is what the agent reads.

Each run checks the repository out in its own sandbox, renders and validates, and opens its own pull request linking the issue. An automation run has its own max_runs_per_hour cap, and two issues labelled on the same day get two sandboxes and two pull requests.

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

Why run it on Rush?

Twelve autoscaler objects are easy to template and easy to get subtly wrong: a targetRef with the wrong name, a bound that lets the recommender suggest less than the service needs, or a mode that evicts pods on a Friday. Reading each Deployment's requests and limits first and deriving the bounds from them, then validating the render against the real schema, is what the sandbox is for, and the pull request carries that render and validation output so the review is about the bounds, not the syntax.

The same body runs against every manifest repository an organisation keeps, each in its own sandbox with its own Deployment table, so a dozen clusters start collecting recommendations the same week with the same conservative mode, and the record of what was rendered and checked stays with each pull request.

Frequently asked questions

Will this change my pods' resources?

No. updateMode: "Off" tells the recommender to compute and publish recommendations only; nothing evicts a pod or edits a request. Moving to Initial, which applies recommendations only when a pod is created, or Auto, is a one-field change the docs page describes.

Do we need something installed in the cluster?

Yes. The VerticalPodAutoscaler kind comes from the VPA custom resource definitions, and recommendations appear only when the recommender is running. Managed Kubernetes services offer it as a setting; elsewhere it is installed from the autoscaler project. The component is inert until enabled, so merging before the cluster is ready is safe.

Can VPA and HPA run on the same Deployment?

Not on the same metric. This repository has no HorizontalPodAutoscaler, so there is no conflict today; if one is added later on CPU, the VPA for that Deployment should control memory only, which is what controlledResources is for.

Why bound the recommendations at all?

Because the recommender has no idea what the authors learned the hard way. minAllowed at the current request stops a quiet week from recommending less than the service needs under load; maxAllowed at the current limit keeps a recommendation inside the headroom already accepted. Both are easy to widen once the numbers have been read.

What about the Helm chart?

The pull request leaves helm-chart/ alone and says so, since the chart has its own values structure and its own CI. Adding an autoscaling.vertical.enabled toggle there with the same bounds taken from values.yaml is the natural follow-up.

More Kubernetes jobs

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

Keep reading