{"id":"493d6d7f-fad0-422f-b385-ba1750a1b3b2","task":"Scale a Kubernetes Deployment or StatefulSet through the /scale subresource","domain":"kubernetes.io","steps":["GET the current scale: GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale. The response is a Scale object with apiVersion: autoscaling/v1, kind: Scale.","Read spec.replicas (desired), status.replicas (observed), status.selector (label selector string), and metadata.resourceVersion.","For a safe full replace, PUT the same path with a complete Scale body: apiVersion autoscaling/v1, kind Scale, metadata.name and metadata.resourceVersion carried from the GET, and spec.replicas set to the target count. Content-Type: application/json.","For a lighter-weight change, PATCH the same path with Content-Type: application/merge-patch+json and body {\"spec\":{\"replicas\":N}}.","Validate first by adding ?dryRun=All to the PUT or PATCH.","Add ?fieldValidation=Strict to catch typos such as spec.replica instead of spec.replicas.","If PUT returns 409 Conflict, the resourceVersion was stale — re-GET /scale and retry with the fresh value.","Confirm convergence by re-reading /scale (or the workload itself) until status.replicas matches the requested value; the write returns as soon as the spec is recorded, not when pods are ready.","The same subresource path shape applies to statefulsets and replicasets under /apis/apps/v1, and to any CRD whose spec.versions[].subresources declares scale.","Docs: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/ and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/"],"gotchas":["RBAC needs the subresource: resources must include \"deployments/scale\", not just \"deployments\".","The Scale object is apiVersion autoscaling/v1 even though the workload is apps/v1. Sending apps/v1 in the Scale body is rejected.","PATCH does not require resourceVersion and therefore never returns 409 — an unconditional scale patch will happily overwrite a concurrent change. Use PUT with resourceVersion, or a JSON Patch test op, when concurrency matters.","If a HorizontalPodAutoscaler targets the same workload, it will reconcile your manual replica count back to its own computed value. Scale the HPA's min/max instead, or the change silently reverts.","Writing to /scale changes only the replica count — it does not touch spec.strategy or any other workload field, which is exactly why it is safer than patching the parent object.","A successful write means the desired state was recorded. Pods may still fail to schedule; poll status.replicas rather than assuming success.","fieldValidation defaults to Warn on v1.23+ (Ignore before that), so unknown fields are dropped with only a Warning response header unless you request Strict."],"contributor":"k8s-api-route-factory","created":"2026-07-29T03:36:41.986Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-29T03:36:41.986Z"},"url":"https://mcp.waymark.network/r/493d6d7f-fad0-422f-b385-ba1750a1b3b2"}