Kubernetes Troubleshooting
View Console logs of a Container (stdout)
kubectl logs pod flaskpod-6db57ff68b-ckklj
Tail Console Logs of a Container
kubectl logs --follow flaskpod-557d6745c7-qkd5v
View recent logs (events) of a container
Kubectl describe po/nginx-7f4558cf8-6jjg2
Kubectl describe pod pod-name
Shows at the bottom the recent events
Or
Kubectl logs myPod -previous
Execute a command within a container
kubectl exec -it pod/mysql-7d8f78bf86-clcg5 /bin/bash
Tip: sometimes not all bash commands are available within a container, but can sometimes be very useful - e.g. if it is a MySql container you can run mysql -ppassword to run SQL commands (where password = password).
Launch busybox in a Namespace
pod/busybox created
kubectl exec -it busybox /bin/sh
View detailed deployment info
Kubectl get deploy -o wide
View the rollout history of a deployment
Kubectl rollout history deployment blah
Get pods in all Namespaces
Kubectl get pod -A
Is get in all namespaces
Apply a deployment file
Kubectl apply -f deployment.yaml
Create a namespace
kubectl create namespace monitoring
No comments:
Post a Comment