Difference between revisions of "Kubectl patch"

From wikieduonline
Jump to navigation Jump to search
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
 +
* https://jamesdefabia.github.io/docs/user-guide/kubectl/kubectl_patch/
 +
[[Update]] field(s) of a [[resource]] using strategic merge patch.
 +
 +
 
  [[kubectl patch --help]]
 
  [[kubectl patch --help]]
 +
    -p, --patch='':
 +
The patch to be applied to the resource JSON file.
  
 
  [[kubectl patch svc]] argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
 
  [[kubectl patch svc]] argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
  
 
  [[kubectl patch pv]]
 
  [[kubectl patch pv]]
 +
 +
[[kubectl patch pvc]]
  
 
  [[kubectl patch sts elastic-operator]]
 
  [[kubectl patch sts elastic-operator]]
  
  [[kubectl patch cronjobs]]  
+
  [[kubectl patch cronjobs]]
 +
 
 +
[[kubectl patch provisioner]] 
 +
 
 +
[[kubectl patch ValidatingWebhookConfiguration]]
 +
 
 +
[[Stop DaemonSet]] by appliying a [[nodeSelector]]
 +
* <code>[[kubectl patch daemonset]] <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'</code>
 +
Start [[DaemonSet]] by removing the [[nodeSelector]] :
 +
kubectl patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'
 +
 
 +
[[kubectl get ds -A]]
 +
 
 +
[[kubectl patch --type]]=json -p='[{"op": "remove", "path": "[[metadata.creationTimestamp]]"}]'
 +
 
 +
 
 +
 
 +
 
 +
== Related ==
 +
* <code>[[K8s.io/Patch]]</code>
 +
 
 +
* <code>[[kubectl replace]]</code>
 +
 
 +
* <code>[[kubectl edit]]</code>
 +
* <code>[[kubectl apply]]</code>
 +
 
 +
* [[Kubernetes PVC resize: kubectl patch]]
 +
 
 +
* <code>[[UnsuportedMediaType]]</code>
 +
* <code>[[Unsupported Media Type]]</code>
 +
* <code>[[The request is invalid: the server rejected our request due to an error in our request]]</code>
 +
* <code>[[sed]]</code>
  
 
== See also ==
 
== See also ==

Latest revision as of 10:15, 28 February 2024

Update field(s) of a resource using strategic merge patch.


kubectl patch --help
   -p, --patch=:

The patch to be applied to the resource JSON file.

kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
kubectl patch pv
kubectl patch pvc
kubectl patch sts elastic-operator
kubectl patch cronjobs
kubectl patch provisioner  
kubectl patch ValidatingWebhookConfiguration

Stop DaemonSet by appliying a nodeSelector

  • kubectl patch daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'

Start DaemonSet by removing the nodeSelector :

kubectl patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'
kubectl get ds -A
kubectl patch --type=json -p='[{"op": "remove", "path": "metadata.creationTimestamp"}]'



Related[edit]

See also[edit]

Advertising: