• Kubernetes service中的故障排查

    Kubernetes service中的故障排查

    • 查看某个资源的定义和用法
    1. kubectl explain
    • 查看Pod的状态
    1. kubectl get pods
    2. kubectl describe pods my-pod
    • 监控Pod状态的变化
    1. kubectl get pod -w

    可以看到一个 namespace 中所有的 pod 的 phase 变化,请参考 Pod 的生命周期。

    • 查看 Pod 的日志
    1. kubectl logs my-pod
    2. kubectl logs my-pod -c my-container
    3. kubectl logs -f my-pod
    4. kubectl logs -f my-pod -c my-container

    -f 参数可以 follow 日志输出。

    • 交互式 debug
    1. kubectl exec my-pod -it /bin/bash
    2. kubectl top pod POD_NAME --containers