# Add Resource Requests and Limits to a Helm Chart

Yes. An agent adds a resources block to your chart's values and Deployment template, a CI values file that exercises it, lints and renders the chart, and opens a PR.

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

## What the agent does

The agent reads the chart before it edits a template. In a repository laid out like helm/examples, there is one chart, `charts/hello-world`, at version 0.1.0 with `appVersion` 1.16.0. `values.yaml` declares `replicaCount`, an `image` (`nginx`, `pullPolicy: IfNotPresent`, empty `tag` so the template falls back to `appVersion`), `nameOverride` and `fullnameOverride`, a `serviceAccount` block and a `service` of type `ClusterIP` on port 80, and nothing else: no `resources` key at all. `templates/deployment.yaml` renders one container named after the chart with an `http` port on 80 and `livenessProbe` and `readinessProbe` on `/`, and no `resources` field, so every pod runs with no request and no limit and lands in the `BestEffort` QoS class. `_helpers.tpl` defines the usual `name`, `fullname`, `chart`, `labels`, `selectorLabels` and `serviceAccountName` helpers, `service.yaml` and `serviceaccount.yaml` use them, and `README.md` in the chart is one heading.

It also reads how the repository checks itself, because that decides how the change is proved. `ct.yaml` points chart-testing at `charts/`. `.github/workflows/lint-test.yaml` runs on every pull request: `ct list-changed`, `ct lint`, and when a chart changed, a kind cluster and `ct install`. `.github/workflows/release.yaml` runs chart-releaser on every push to `main`, which publishes a chart only when the version in `Chart.yaml` is one it has not released, so a change to the templates without a version bump ships nothing.

The change is the one the Helm starter chart makes and this example left out. `values.yaml` gains `resources: {}` with a comment showing the four keys (`limits.cpu`, `limits.memory`, `requests.cpu`, `requests.memory`) and the reasoning that a default of nothing lets the chart install on a small cluster while an operator sets real numbers per environment. `templates/deployment.yaml` gains `{{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }}` on the container, so an empty map renders nothing and a filled one renders exactly what was given. The agent adds `charts/hello-world/ci/resources-values.yaml`, which chart-testing picks up by convention, with requests and limits set, so `ct lint` and `ct install` exercise the block on every pull request rather than only the empty default. It bumps `Chart.yaml` to 0.2.0 and writes the new value into the chart's `README.md` as a short table.

Then it proves the render. It runs `helm lint charts/hello-world`, `helm template hello charts/hello-world` to show the container without a `resources` field, `helm template hello charts/hello-world -f charts/hello-world/ci/resources-values.yaml` to show it with one, and `ct lint --config ct.yaml` as the workflow does. A kind cluster is more than the sandbox needs for a template change, so the agent validates the rendered Deployment against the Kubernetes schema with `kubeconform` instead and says so in the pull request; `ct install` runs in CI when the pull request opens.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add resource requests and limits to the Helm chart in this repository. Read Chart.yaml, values.yaml, templates/deployment.yaml, templates/_helpers.tpl, the chart README, ct.yaml and the workflows under .github first. Add a resources key to values.yaml that defaults to an empty map with a comment showing limits and requests for cpu and memory, render it on the container in templates/deployment.yaml with a with block and toYaml so an empty value renders nothing, add a ci/ values file that sets requests and limits so chart-testing exercises the block, bump the chart version, and document the value in the chart README. Run helm lint, helm template with and without the ci values, ct lint with the repository's ct.yaml, and kubeconform on the rendered Deployment, and open a pull request that quotes the two renders of the container and the lint 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

The pull request changes `charts/hello-world/Chart.yaml`, `values.yaml`, `templates/deployment.yaml` and `README.md`, and adds `charts/hello-world/ci/resources-values.yaml`. Its description shows the rendered container twice, once with no `resources` field and once with the four keys from the CI values, and quotes `helm lint`, `ct lint` and `kubeconform` output from the sandbox. The repository's own `lint-test.yaml` workflow then runs `ct install` on a kind cluster for the changed chart.

A reviewer checks the template indentation (`nindent 12` puts `resources` level with `ports` and the probes), decides whether the CI values are reasonable for the `ct install` cluster, and confirms the version bump so chart-releaser publishes the chart on merge. Nothing else in the chart changed, which the first render in the description shows.

From then on an operator sets `resources` in a per-environment values file or with `--set`, and a cluster with a `LimitRange` or a `ResourceQuota` admits the pod on the operator's terms rather than refusing it.

## Run it on every chart added under charts/

An automation on the Project with a `github` trigger on `pull_request.opened` and the prompt "if this pull request adds a chart under charts/ or a Deployment template, check that every container renders a resources block from values and that a ci/ values file sets it, and post a review that quotes the render" runs once per pull request. The trigger adds the pull request after the prompt and fills in nothing else; the run reads the diff to decide. Only work by an owner, member or collaborator fires it.

A platform team with several chart repositories sends this body once per repository from its own server, each `POST /o/{org}/sessions` with that repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own charts: one with several Deployments gets the block on each container, and one that already has `resources` in values but not in a template gets only the template fixed.

## Why run it on Rush?

A missing `resources` block is invisible until a cluster with a quota refuses the pod or a noisy neighbour starves it, and the fix is easy to get wrong by two spaces of indentation that `helm lint` does not catch. The agent renders the chart both ways, validates the output against the Kubernetes schema, runs the same chart-testing lint as the repository's CI, and keeps every command and its output with the pull request.

A reviewer reads two renders of one container rather than running Helm locally. A team with many charts starts the same request across all of them at once.

## Frequently asked questions

### Why does the default stay empty?

The chart is installed on clusters the author cannot see, from a laptop kind cluster to a production node pool, and a hard-coded limit that suits one starves or wastes another. An empty map renders nothing, so the chart installs as before, and the CI values file proves the block works when it is set.

### What numbers go in the CI values?

Small ones that an `nginx` container and a kind cluster accept, so `ct install` passes. They are a test of the template, not a recommendation; the pull request says so and the README tells operators to size the values for their own workload.

### Does this change the QoS class?

Only when values are set. With requests equal to limits the pod is `Guaranteed`; with requests below limits it is `Burstable`; with the empty default it stays `BestEffort`, as it is today. The README table in the pull request states this.

### Why bump the chart version?

The release workflow runs chart-releaser on `main`, which publishes a chart only when `Chart.yaml` carries a version it has not seen. Without the bump the new value would be merged but never released.

## More Helm jobs

- [Add Pod and Container Security Contexts to a Helm Chart](https://getrush.ai/run/add-security-context/helm/)
- [Add a ServiceMonitor to a Helm Chart](https://getrush.ai/run/add-service-monitors/helm/)
- [Add a values.schema.json to a Helm Chart](https://getrush.ai/run/add-values-schema/helm/)

## The same job on other stacks

- [Add Resource Requests and Limits to Kubernetes Manifests from a Linear Issue](https://getrush.ai/run/add-resource-limits/kubernetes/)
- [Add Resource Requests and Limits to a Kustomize App from a Linear Issue](https://getrush.ai/run/add-resource-limits/kustomize/)
- [Add Resource Limits to a Docker Compose Stack](https://getrush.ai/run/add-resource-limits/docker-compose/)

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