kubectl-patch
updates fields of a resource using strategic merge patch, JSON merge
TLDR
Patch deployment with JSON
SYNOPSIS
kubectl patch type name [options]
DESCRIPTION
kubectl patch applies incremental updates to Kubernetes resource fields without requiring you to replace the entire resource specification. This makes it well suited for scripted and automated changes where only specific fields need modification, such as adjusting replica counts, updating image tags, or adding annotations.
The command supports three patch strategies: strategic merge patch (the default), which intelligently merges lists and maps according to Kubernetes schema knowledge; JSON merge patch, which performs a straightforward recursive merge; and JSON patch (RFC 6902), which uses explicit operations like add, remove, and replace on specific JSON paths. Patch content can be provided inline via the -p flag or read from a file with --patch-file.
PARAMETERS
-p, --patch patch
Patch content as JSON or YAML.--patch-file file
File containing patch.--type type
Patch type (strategic, merge, json).-n, --namespace name
Kubernetes namespace.
SEE ALSO
kubectl(1), kubectl-edit(1)
