Kubectl patch: Difference between revisions
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
* [[Kubectl#Commands|kubectl]] | * [[Kubectl#Commands|kubectl]] | ||
* [[Kubernetes Strategic Merge Patch]] | * [[Kubernetes Strategic Merge Patch]] | ||
* [[ | * [[JSON Merge Patch]] | ||
* [[JSON Patch]] | * [[JSON Patch]] | ||
Revision as of 17:47, 29 July 2021
External
- https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#patch
- https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/
Internal
Overview
kubectl patch
supports the following modes: strategic merge patch ("strategic"), JSON merge patch ("merge") and JSON patch ("json").
Caveats
⚠️There are situations when the patch apparently succeeds, the kubectl patch
command exits with 0 and if the resource is queried immediately, the patch seems to be applied, but when the resource is queried a while later (15 secs), it becomes apparent that the "patch" did not take. This happened while trying to unbind a PV from the PVC while the PVC is still active.
Usage Examples
Delete a Field with a JSON Patch
Unbind a PVC from a PV by deleting the PV's claimRef
:
kubectl patch pv my-pv --type=json --patch='[{"op": "remove", "path": "/spec/claimRef"}]'