Patch a resource field

Changes one field with an inline JSON patch, without editing the whole manifest

kubectl patch deployment <name> -n <ns> -p '{"spec":{"replicas":2}}'

tool
kubectl73 commands
tags
deploymentsconfig

More kubectl commands

  • kubectl annotate pod <pod> -n <ns> key=value --overwrite

    Adds or updates an annotation; --overwrite replaces the existing value

  • kubectl label node <node> role=worker --overwrite

    Adds or changes a label on any resource, here on a node

  • kubectl taint nodes <node> key=value:NoSchedule

    Pods without a matching toleration will not be scheduled on this node

  • kubectl taint nodes <node> key=value:NoSchedule-

    Removes the taint; all the magic is in the dash at the end

  • kubectl set image deployment/<name> <container>=image:tag -n <ns>

    Starts a rolling update with a new container image, no YAML editing

all 73 kubectl commands