Kubectl patch: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 5: Line 5:


=Overview=
=Overview=
<code>kubectl patch</code> supports [[Kubernetes Strategic Merge Patch|strategic merge patch]].
<code>kubectl patch</code> supports the following modes: [[Kubernetes Strategic Merge Patch|strategic merge patch]], JSON merge patch and JSON patch.
 
=Caveats=
=Caveats=
⚠️There are situations when the patch apparently succeeds, the <code>kubectl patch</code> 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.
⚠️There are situations when the patch apparently succeeds, the <code>kubectl patch</code> 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.

Revision as of 17:28, 29 July 2021

External

Internal

Overview

kubectl patch supports the following modes: strategic merge patch, JSON merge patch and JSON patch.

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

Unbind a PVC from a PV by deleting the PV's claimRef:

kubectl patch pv my-pv --type=json -p='[{"op": "remove", "path": "/spec/claimRef"}]'