kx patch
Patches one indexed resource via kubectl patch. The patch itself is kubectl’s: -p gives it inline, --patch-file reads it from a file, and --type picks strategic (the default), merge or json.
kubectl’s other flags pass through too — --dry-run to preview the change, -o to print the patched object, --subresource to patch status or scale. -f, -k and --local are refused, since each names the resource to patch, which the index already does, and -R with them, since it only applies to -f.
A flag kx doesn’t know is refused; put it after -- to pass it through to kubectl.
Usage
kx patch [OPTIONS] <index> [kubectl flags]Arguments
| Argument | Description |
|---|---|
<index> | Row number from the current listing, @name for a mark, or kind/name such as deploy/api |
Options
| Option | Description |
|---|---|
--dry-run[=string] | client or server to preview the change without making it, as kubectl takes it; kx’s line says nothing was changed |
-o, --output string | Output format, as kubectl takes it; kubectl’s output is printed, and kx’s own lines go to stderr |
Passthrough options
| Option | Description |
|---|---|
--allow-missing-template-keys | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. |
--field-manager string | Name of the manager used to track field ownership. |
-p, --patch string | The patch to be applied to the resource JSON file. |
--patch-file string | A file containing a patch to be applied to the resource. |
--show-managed-fields | If true, keep the managedFields when printing objects in JSON or YAML format. |
--subresource string | If specified, patch will operate on the subresource of the requested object. |
--template string | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. |
--type string | The type of patch being provided; one of [json merge strategic] |
… | kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them |
Global options
| Option | Description |
|---|---|
--no-color | Disable styled output |
-h, --help | Show this message and exit |
Examples
kx patch 1 -p '{"spec":{"replicas":2}}'
kx patch 1 --type merge -p '{"metadata":{"labels":{"tier":"web"}}}'
kx patch 1 --type json -p '[{"op":"remove","path":"/spec/paused"}]'
kx patch deploy/api --patch-file fix.yaml -n prod --dry-run=server