CmdID

CmdID / Commands

kubectl-patch

Patch Kubernetes resources with new values. tldr-pages

On several platforms

Opens CmdID with your command. It is read in your browser and sent nowhere.

Several platforms

from tldr-pages, CC BY 4.0

Partially patch a secret using a strategic merge JSON patch to remove the finalizer

kubectl patch secrets secret_name --patch '{"metadata":{"finalizers": []\}\}' --type mergeIdentify
--patchThe patch to be applied to the resource JSON file. kubectl reference
--typeThe type of patch being provided; one of [json merge strategic] kubectl reference

Partially patch a secret using a strategic merge YAML patch to remove the finalizer

kubectl patch secrets secret_name --patch $'metadata:\n finalizers: []' --type mergeIdentify
--patchThe patch to be applied to the resource JSON file. kubectl reference
--typeThe type of patch being provided; one of [json merge strategic] kubectl reference

Partially patch a pod's container using a JSON patch with positional arrays

kubectl patch [po pod_name --type 'json' --patch '[{"op": "replace", "path": "/spec/containers/0/image", "value":"new_image_value"}]'Identify
--typeThe type of patch being provided; one of [json merge strategic] kubectl reference
--patchThe patch to be applied to the resource JSON file. kubectl reference

Update a deployment's replicas through the scale subresource using a strategic merge JSON patch

kubectl patch [deploy deployment_name --subresource 'scale' --type 'merge' --patch '{"spec":{"replicas":number_of_replicas\}\}'Identify
--subresourceIf specified, patch will operate on the subresource of the requested object. kubectl reference
--typeThe type of patch being provided; one of [json merge strategic] kubectl reference
--patchThe patch to be applied to the resource JSON file. kubectl reference