Patch resource field

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

    Set or update an annotation; --overwrite replaces existing value

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

    Add or change a label on any resource

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

    Prevent pods without matching toleration from scheduling on node

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

    Remove a taint by appending a dash at the end

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

    Rolling-update the container image without editing YAML

all 73 kubectl commands