Skip to content

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

ArgumentDescription
<index>Row number from the current listing, @name for a mark, or kind/name such as deploy/api

Options

OptionDescription
--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 stringOutput format, as kubectl takes it; kubectl’s output is printed, and kx’s own lines go to stderr

Passthrough options

OptionDescription
--allow-missing-template-keysIf 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 stringName of the manager used to track field ownership.
-p, --patch stringThe patch to be applied to the resource JSON file.
--patch-file stringA file containing a patch to be applied to the resource.
--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.
--subresource stringIf specified, patch will operate on the subresource of the requested object.
--template stringTemplate 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 stringThe 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

OptionDescription
--no-colorDisable styled output
-h, --helpShow 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