[Kubernetes] Inspecting Kubernetes Object
Inspecting Kubernetes Object
- get
- describe
- logs
- Watching recreation of Pods
get
# get common information
kubectl get all
kubectl get all -o wide
kubectl get all -o yaml
# get all nodes
kubectl get nodes
# get all namespaces
kubectl get namespaces
# get pods
kubectl get pods
# keep watching
kubectl get pods -w
# get particular information of a node
kubectl get node docker-desktop -o wide
# get events
kubectl get events
# get events continually after the command
kubectl get events --watch-only
describe
# all pods
kubectl describe pods
# describe specific pod(kubectl describe pod {pod_name})
kubectl describe pod my-apache-6f45bc5bd9-hd2lv
# describe node(kubectl describe node/{node_name})
kubectl describe node/docker-desktop
# describe specific pods(kubectl describe pods {pod_name})
kubectl describe pods my-apache-6f45bc5bd9-4vvw9
# describe deployments(kubectl describe deploy {deployment_name})
kubectl describe deploy my-apache
logs
- May need third-party to get centeralized logging system
- 🔗 참고
- utility to to find logs easily without a centralized, searchable logging sollution
- collect logs from multiple containers, colors differently by containers, etc.
# get running pods
kubectl get pods
# get container logs(kubectl logs deploy/{de}})
# picks a random replica and the first container
kubectl logs deploy/my-apache
# specifiy container in pod and follow
kubectl logs pod/my-apache-6f45bc5bd9-hd2lv -c httpd -f --tail 1
# get all logs inside a pod
kubectl logs pod/my-apache-6f45bc5bd9-hd2lv --all-containers
# get logs only matching specific label
# label information can be retrieved using 'kubectl describe deploy my-apache'
kubectl logs -l app=my-apache
Watching recreation of Pods
# watch pods in runtime
kubectl get pods -w
# delete pods(kubectl delete pod {pod_name})
kubectl delete pod my-apache-6f45bc5bd9-4vvw9
# don't forget to delete the remaining deployment for experiment
# kubectl delete deployment my-apache