patch_resource
Patch existing Kubernetes resources with JSON Patch, JSON Merge Patch, or strategic merge patch for precise field mutations like removing or replacing specific values.
Instructions
Patch one existing Kubernetes resource with JSON Patch, JSON Merge Patch, or strategic merge patch. Use this for precise field/list mutations such as removing a bad dnsConfig, hostPort, initContainers field, sidecar container, nodeSelector, or replacing one scalar value. Prefer this over apply_resource when you know the exact field to mutate and do not want to rewrite the full manifest or take broad server-side-apply ownership. For patch_type=json, patch must be an RFC 6902 JSON Patch array. For patch_type=merge, patch must be a JSON object. For patch_type=strategic, use a JSON object against built-in Kubernetes kinds when you need name-keyed list merging, such as editing one container. By default returns compact post-patch state and dry-run preview diffs; JSON Patch calls also include per-operation field checks. Set verify=false only when you need a terse write result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | Yes | resource kind, e.g. Deployment, Service, ConfigMap | |
| name | Yes | resource name | |
| group | No | API group when the kind is ambiguous, e.g. apps for Deployment or serving.knative.dev for Knative Service | |
| patch | Yes | JSON patch body. For patch_type=json, pass an array like [{"op":"remove","path":"/spec/template/spec/dnsConfig"}]. For merge/strategic, pass an object. | |
| verify | No | return compact post-patch state; on dry_run return a preview diff. JSON Patch calls also include field checks. Default true; set false for a terse write result. | |
| dry_run | No | validate and preview the server-side result without persisting changes | |
| namespace | No | namespace for namespaced resources; omit for cluster-scoped resources | |
| patch_type | No | json (default, RFC 6902 JSON Patch array), merge (JSON Merge Patch object), or strategic (built-in Kubernetes kinds only) |