1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-03 14:55:24 +02:00
tldr/pages/common/kubectl.md
Managor 23340cc6e0
common/*: reduce usage of "command-line" (part 1) (#16949)
Co-authored-by: Dylan <145150333+dmmqz@users.noreply.github.com>
Co-authored-by: Lena <126529524+acuteenvy@users.noreply.github.com>
2025-06-29 11:48:18 +03:00

944 B

kubectl

Run commands against Kubernetes clusters. Some subcommands such as run have their own usage documentation. More information: https://kubernetes.io/docs/reference/kubectl/.

  • List information about a resource with more details:

kubectl get {{pod|service|deployment|ingress|...}} {{[-o|--output]}} wide

  • Update specified pod with the label 'unhealthy' and the value 'true':

kubectl label pods {{name}} unhealthy=true

  • List all resources with different types:

kubectl get all

  • Display resource (CPU/Memory/Storage) usage of nodes or pods:

kubectl top {{pod|node}}

  • Print the address of the master and cluster services:

kubectl cluster-info

  • Display an explanation of a specific field:

kubectl explain {{pods.spec.containers}}

  • Print the logs for a container in a pod or specified resource:

kubectl logs {{pod_name}}

  • Run command in an existing pod:

kubectl exec {{pod_name}} -- {{ls /}}