tldr/pages/common/kubectl.md

37 lines
895 B
Markdown
Raw Normal View History

2018-01-30 15:51:25 +00:00
# kubectl
> Command line interface for running commands against Kubernetes clusters.
2019-08-16 10:23:03 +01:00
> More information: <https://kubernetes.io/docs/reference/kubectl/>.
2018-01-30 15:51:25 +00:00
2019-08-16 10:23:03 +01:00
- List all information about a resource with more details:
2018-01-30 15:51:25 +00:00
2019-08-16 10:23:03 +01:00
`kubectl get {{pod|service|deployment|ingress|...}} -o wide`
2018-01-30 15:51:25 +00:00
- 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`
2019-08-16 10:23:03 +01:00
- Display resource (CPU/Memory/Storage) usage of nodes or pods:
2018-01-30 15:51:25 +00:00
2019-08-16 10:23:03 +01:00
`kubectl top {{pod|node}}`
2018-01-30 15:51:25 +00:00
- Print the address of the master and cluster services:
`kubectl cluster-info`
2019-08-16 10:23:03 +01:00
- 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:
2019-08-16 10:23:03 +01:00
`kubectl exec {{pod_name}} -- {{ls /}}`