website icon indicating copy to clipboard operation
website copied to clipboard

Add a YAML example to kubectl patch doc

Open nikhiljindal opened this issue 10 years ago • 15 comments

kubectl patch doc says that both YAML and JSON formats are supported, but all examples are in JSON form. We should add atleast one YAML example.

User asking about YAML format: http://stackoverflow.com/questions/36920171/how-can-i-edit-a-deployment-without-modify-the-file-manually#comment61508585_36924484

cc @kubernetes/docs

nikhiljindal avatar May 02 '16 21:05 nikhiljindal

I tried the following YAML patch:

$ ./cluster/kubectl.sh patch nodes 127.0.0.1 -p '"spec.unschedulable": true'

I got "127.0.0.1" patched response which made me think that the patch succeeded, but looking at the output of kubectl get nodes it didnt.

nikhiljindal avatar May 02 '16 21:05 nikhiljindal

cc @kubernetes/kubectl

bgrant0607 avatar May 03 '16 06:05 bgrant0607

We need an example generated.

jaredbhatti avatar Jan 11 '17 20:01 jaredbhatti

Ping. This would still be great to have. Not sure how to accomplish this currently:

~$ kubectl patch statefulset/web -p ' "spec.replicas": 4'
statefulset "web" not patched

ryanmcginnis avatar Jul 12 '17 16:07 ryanmcginnis

This works for me (note the $): kubectl patch deployment in-place-demo --patch $'spec:\n replicas: 5' deployment "in-place-demo" patched kubectl get deployment in-place-demo --output=yaml spec: ... replicas: 5

steveperry-53 avatar Jul 27 '17 23:07 steveperry-53

I'm working on a new Task topic that will cover kubectl edit and kubectl patch: https://github.com/kubernetes/kubernetes.github.io/pull/4519

steveperry-53 avatar Jul 27 '17 23:07 steveperry-53

This also works. Create patch-file.yaml with this content:

spec:
 replicas: 6

Note the double quotes. kubectl patch deployment in-place-demo --patch "$(cat patch-file.yaml)"

steveperry-53 avatar Jul 28 '17 19:07 steveperry-53

attn: @nikhiljindal, @ryanmcginnis, @jaredbhatti

steveperry-53 avatar Jul 28 '17 19:07 steveperry-53

Fixed in https://github.com/kubernetes/kubernetes/pull/50532.

So I don't understand why the fix doesn't appear here: https://kubernetes.io/docs/user-guide/kubectl/v1.8/#patch.

cc @pwittrock @chenopis

steveperry-53 avatar Oct 05 '17 03:10 steveperry-53

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta. /lifecycle stale

fejta-bot avatar Jan 07 '18 04:01 fejta-bot

/remove-lifecycle stale

Steve, did you ever figure out why the fix didn't generate in the API docs?

ryanmcginnis avatar Jan 08 '18 17:01 ryanmcginnis

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Apr 08 '18 18:04 fejta-bot

/remove-lifecycle stale

ryanmcginnis avatar Apr 09 '18 16:04 ryanmcginnis

The docs generated actually contains this info. See: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#patch Feel free to reopen if that is not what you want. /close

tengqm avatar Jun 17 '18 06:06 tengqm

I am trying to patch node condition type status, is there any example for that ?

Shikaz avatar May 20 '22 04:05 Shikaz