All jobs

Add Resource Requests and Limits to Kubernetes Manifests from a Linear Issue

Yes. Label the Linear issue and an agent adds resources blocks to every container in your Deployment manifests, validates the YAML and opens a linked 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 reads the issue first, then every manifest it points at. In a repository shaped like dockersamples/example-voting-app the Kubernetes files live in k8s-specifications/: five Deployments (vote, result, worker, redis and db) and four Services, applied with kubectl create -f k8s-specifications/ as the README says. Each Deployment has one container, replicas: 1, and no resources block at all. The images tell it what each container is: postgres:15-alpine with an emptyDir volume under /var/lib/postgresql/data, redis:alpine with an emptyDir under /data, and the three app images built from vote/, result/ and worker/. There are no probes either, so a container that starts but cannot reach Redis looks healthy; the agent notes that as out of scope unless the issue asks.

The values come from the issue, not from the agent. The Linear trigger puts the issue text after the prompt, so an issue like db and redis need requests and limits before we enable the autoscaler, 250m/256Mi requests, 500m/512Mi limits, app pods half that gives it everything. When the issue names services but no numbers, the agent asks on the issue rather than guessing, because this repository records no measurements: there is no HorizontalPodAutoscaler, no metrics-server manifest and no load test output to read. What it can read is the code, and it uses that to explain the shape of each workload in the pull request: vote/app.py runs under gunicorn with four workers per the Dockerfile's final stage, result/server.js polls Postgres every second and pushes to Socket.IO clients, and worker/Program.cs sits in a loop that sleeps 100 milliseconds between Redis pops, so its CPU is steady and small.

It edits the five Deployments in place, adding resources.requests and resources.limits to each container with the issue's numbers, and keeps requests equal to limits where the issue asks for Guaranteed QoS. The edits are the only change: no reformatting of the files, no version bumps on the images, no new fields. It then validates: kubeconform -strict -summary k8s-specifications/ against the apps/v1 and v1 schemas, kubectl apply --dry-run=client -f k8s-specifications/, and a git diff --stat to show that only the five Deployment files changed. If the sandbox can start a kind cluster, it applies the manifests there and checks that each pod schedules and reaches Running rather than sitting in Pending, which is what a request larger than a node would produce.

The pull request links the issue by its identifier in the description, lists each container with its new requests and limits in a table, quotes the kubeconform summary and the dry-run output, and names what it did not change: docker-compose.yml and docker-stack.yml, which have their own deploy sections and are not Kubernetes files, and the Services, which need nothing.

Start it with one API call

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

{
  "agent": "claude",
  "input": "A Linear issue labelled agent asks for resource requests and limits on the Kubernetes manifests. Read README.md and every file in k8s-specifications/ first, and list each Deployment's containers, images and any existing resources blocks. Read vote/app.py, vote/Dockerfile, result/server.js, result/Dockerfile and worker/Program.cs to describe what each container does. Use the values the issue gives; if the issue names workloads without numbers, comment on the issue asking for them and stop. Add resources.requests and resources.limits to every container the issue covers, editing the Deployment files in place and changing nothing else. Run kubeconform -strict -summary and kubectl apply --dry-run=client on the directory, and if a kind cluster can be started, apply the manifests and confirm every pod schedules. Open a pull request that links the issue, tables each container's values, quotes the validation output and says what was left unchanged.",
  "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 that edits vote-deployment.yaml, result-deployment.yaml, worker-deployment.yaml, redis-deployment.yaml and db-deployment.yaml, each gaining a resources block under its single container with the issue's requests and limits, and touches nothing else in k8s-specifications/. The description links the Linear issue and carries a table of container, image, request and limit, so the reviewer sees the whole picture without opening five files.

Under the table is the validation: the kubeconform summary with its counts of valid resources, the client-side dry run, and, when a cluster was available in the sandbox, the kubectl get pods output showing each pod Running. If any pod stayed Pending because a request exceeded the node, that output is quoted too and the run ends needs_review rather than claiming success.

Before merging, a reviewer compares the table against the issue, checks that the database's limit leaves room for Postgres's shared buffers on their actual nodes, and decides whether a LimitRange or a ResourceQuota for the namespace should follow. If they want different numbers, a comment on the issue and a follow-up on the same session changes the five files and pushes to the same pull request.

Run it on every Linear issue labelled agent

Sign in to Linear once with POST /me/connections {"type": "app", "name": "linear"} and finish the authorize URL in the console. Then add an automation to the Project with this prompt and a linear trigger on linear.issue.labeled, naming the label in config.labels. The trigger adds the issue after the prompt and fills in no placeholder, so each run reads which workloads and which numbers from the issue itself. Changes made by an app integration never fire it, so a bot relabelling issues cannot start runs.

Each labelled issue gets its own sandbox and its own pull request, and the automation's max_runs_per_hour caps how many it takes on. A platform team can label one issue per service as it rolls out quotas and get one reviewable pull request per service, each with its own validation output.

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

Why run it on Rush?

Resource blocks are quick to type and easy to get subtly wrong: a Mi where M was meant, a limit below its request, a block indented under the pod spec instead of the container. The only checks that catch those are schema validation and an apply, and a repository like this one has no CI for its manifests, so the first signal would be a sync failure or an eviction. In its own sandbox the agent runs kubeconform and a dry run every time, and a real scheduling test when a cluster is available, before the pull request exists.

The run keeps its record: the issue text it read, each file it changed, every command and its output. A reviewer who did not watch can see that the numbers came from the issue and the validation came from a tool, and the pull request links back to the issue so the decision and the change stay together. Nothing reaches the default branch until a person merges.

Frequently asked questions

Where do the numbers come from?

From the Linear issue. The repository has no autoscaler, no metrics and no load test results, so the agent has nothing to measure against and will not invent values. If the issue names workloads without numbers, the agent asks on the issue and stops instead of guessing.

Will it change docker-compose.yml or docker-stack.yml?

No. Those files describe the Compose and Swarm deployments and have their own deploy sections; Kubernetes reads only k8s-specifications/. The pull request says explicitly that they were left alone.

Does it add liveness and readiness probes while it is there?

Only if the issue asks. The Compose file has health checks for vote, redis and db that would translate well, and the agent mentions that in the pull request, but it keeps the diff to what the issue requested so the review stays small.

What if a pod does not fit on the node?

When a kind cluster is available the agent applies the manifests and watches the pods. A pod stuck in Pending with a FailedScheduling event is quoted in the pull request and the run ends needs_review, so the reviewer sees the problem before the manifests reach a real cluster.

Can it set requests equal to limits for Guaranteed QoS?

Yes, when the issue says so. Equal requests and limits put the pod in the Guaranteed class, which matters for the database and Redis, whose emptyDir data is lost on eviction. The agent notes the QoS class each container ends up in.

More Kubernetes jobs

The same job on other stacks

Keep reading