What are some common kubectl commands?
0
The commands below are used for general troubleshooting, and are immensely helpful to provide when opening a support ticket. They are also used during upgrades, joining/removing nodes and while actively troubleshooting. All the commands below can be run as a one-liner.
1. This will show the status of the pods, jobs and nodes and show additional information in one command:
sudo KUBECONFIG=/etc/kubernetes/admin.conf kubectl get pods,jobs,nodes -o wide
2. Display the logs of a pod (found using the command above), and search for a particular string of text:
sudo KUBECONFIG=/etc/kubernetes/admin.conf kubectl logs [pod name] -f | grep foo
3. Display the logs of a pod that are 1 minute old:
sudo KUBECONFIG=/etc/kubernetes/admin.conf kubectl logs [podname] --since=1m
4. Display the previous logs from a pod that has restarted:
sudo KUBECONFIG=/etc/kubernetes/admin.conf kubectl logs [podname] -p
5. Show the status of Cassandra database:
sudo KUBECONFIG=/etc/kubernetes/admin.conf kubectl exec -ti cassandra-0 nodetool status
Comments
Please sign in to leave a comment.