What the agent does
The agent reads the manifests before it scales anything. In a GKE sample like GoogleCloudPlatform/microservices-demo, kustomize/base/ holds one file per service, eleven in all, from adservice.yaml to shippingservice.yaml; kustomize/kustomization.yaml lists base as its only resource and a commented list of components under kustomize/components/, fifteen variations such as network-policies, memorystore, without-loadgenerator and service-mesh-istio, each a kind: Component. Every Deployment sets requests and limits: the frontend asks for 100m CPU and 64Mi with limits of 200m and 128Mi, the adservice 200m and 180Mi, the recommendationservice 100m and 220Mi with a 450Mi limit, the loadgenerator 300m and 256Mi. None of them sets replicas except the loadgenerator, so each service runs one Pod. cartservice.yaml also carries a second Deployment, redis-cart, and terraform/main.tf creates the cluster with enable_autopilot = true and waits for apiservice/v1beta1.metrics.k8s.io to be available before it applies the manifests, so the metrics the autoscaler reads are already there.
Then it decides what to scale. CPU utilization against the request is the one signal every Deployment here supports, so the agent writes one autoscaling/v2 HorizontalPodAutoscaler per stateless service: frontend, adservice, cartservice, checkoutservice, currencyservice, emailservice, paymentservice, productcatalogservice, recommendationservice and shippingservice, each with scaleTargetRef naming the Deployment, minReplicas: 1 to match today's count, a maxReplicas ceiling and a Resource metric on cpu with a target averageUtilization. Two Deployments are left out on purpose and the pull request says why: redis-cart is a single in-memory store whose data would split across replicas, and the loadgenerator's USERS and RATE environment variables already set the load, so scaling it would multiply the traffic it sends. The files follow the repository's pattern: a new kustomize/components/horizontal-pod-autoscaling/ with a kustomization.yaml of kind: Component, one hpa-<service>.yaml per service like the network-policy-<service>.yaml files, and a README.md in the same shape as the network-policies one, with the kustomize edit add component line.
It checks the result the way the repository's own CI does. .github/workflows/kustomize-build-ci.yaml runs kubectl kustomize . on kustomize/ and kustomize build on every folder under kustomize/tests/, which hold scenarios such as memorystore-with-all-components that stack several components on ../../base. The agent runs both commands in the sandbox, adds the new component to the commented list in kustomize/kustomization.yaml and to each test scenario, and runs kubeconform with the autoscaling/v2 schema over the rendered output so a wrong apiVersion or a scaleTargetRef that names a Deployment the base does not have fails before a cluster sees it. It also renders without-loadgenerator together with the new component to confirm nothing references the Deployment that patch deletes.
What it does not do is pick the ceilings for you. It proposes a maxReplicas per service from the request sizes and the limit the sample's Autopilot cluster would bill for, writes each in a table in the pull request, and notes that the helm-chart/ copy of these manifests gets no autoscalers in this change.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add Horizontal Pod Autoscalers to this GKE application. Read kustomize/kustomization.yaml, every file in kustomize/base, the existing components and kustomize/tests, the Terraform and the kustomize CI workflow first. Write a new Kustomize component with one autoscaling/v2 HorizontalPodAutoscaler per stateless Deployment, scaling on CPU utilization against the request each Deployment already sets, minReplicas equal to today's replica count and a maxReplicas you justify per service. Leave out any Deployment that holds state or generates load, and say so. Give the component a README in the style of the existing ones, add it to the commented list in kustomize/kustomization.yaml and to the test scenarios, and run kubectl kustomize and kustomize build the way the CI workflow does, plus kubeconform over the output. Open a pull request with a table of each service's request, target utilization and ceiling.",
"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
A pull request that adds the component directory, its README, the commented line in the root kustomization and the test-scenario entries. Its description holds the table of services with their CPU request, target utilization and maxReplicas, the two Deployments it skipped with the reason, and the kubectl kustomize, kustomize build and kubeconform output, so the kustomize CI check is expected to pass on the same commands.
A reviewer checks that the targets are the Deployment names in kustomize/base, that the ceilings fit the cluster's quota and budget, and that minReplicas does not raise the Pod count on day one. The autoscalers take effect only when someone adds the component to kustomize/kustomization.yaml and applies it, which is the same step the other components use.
Run it on every Linear issue labelled autoscaling
In the console, add an automation on the Project with a linear trigger on linear.issue.labeled and the label autoscaling, with the prompt above. When a person on the team labels an issue that names a service or a ceiling, the run starts with the issue as its context, writes the component in the Project's repository and opens a pull request on its own branch linked to the issue. A label applied by an app integration never fires it.
From your own tooling, send this body to POST /o/{org}/sessions with the issue text appended to the prompt and a request_id that is a UUID v5 of the issue id, so a retried webhook from your side returns the run already started.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
The decision in this job is which Deployments can scale and what their requests say, and that is answered by reading every manifest and rendering every scenario, not by a template. The agent does that in its own sandbox with kubectl, kustomize and kubeconform installed, and keeps the rendered output and every command in the run's record, so the pull request shows what the CI check will see.
The same run fits any cluster managed with Kustomize components: a platform repository with a base and overlays per environment, or a single application with a handful of Deployments. Each gets autoscalers derived from its own requests and a component that renders beside the ones it already has.
Frequently asked questions
Does this need the metrics server installed on GKE?
GKE runs the metrics API for every cluster, and the sample's Terraform waits for v1beta1.metrics.k8s.io to be available before it applies the manifests. On Autopilot, CPU-based autoscaling works as soon as the Deployment sets a CPU request, which every Deployment here does.
Why is Redis not autoscaled?
redis-cart keeps every cart in memory in one Pod. A second replica would hold a different set of carts, and the cartservice has no way to pick the right one. Scaling it means moving to Memorystore, which the repository already offers as the memorystore component.
Will the autoscalers change my Pod count when I apply them?
No. Each minReplicas is set to the count the Deployment runs today, so applying the component changes nothing until CPU utilization crosses the target. Scale-down follows the controller's default stabilization window, which the pull request names.
Can I use memory or request rate instead of CPU?
Memory works the same way with a memory resource metric, though most of these services hold a steady working set. Request rate needs a custom or external metric source, such as the Google Cloud Managed Service for Prometheus adapter, which is a separate change. A follow-up to the same session can switch one service to memory.