kubernetes实践之五十三:Service中的故障排查

1.查看某种资源的定义和用法
kubectl  explain

点击(此处)折叠或打开

  1. kubectl explain pod
  2. DESCRIPTION:
  3. Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.

  4. FIELDS:
  5.    apiVersion    
  6.      APIVersion defines the versioned schema of this representation of an
  7.      object. Servers should convert recognized schemas to the latest internal
  8.      value, and may reject unrecognized values. More info:
  9.      https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

  10.    kind    
  11.      Kind is a string value representing the REST resource this object
  12.      represents. Servers may infer this from the endpoint the client submits
  13.      requests to. Cannot be updated. In CamelCase. More info:
  14.      https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

  15.    metadata    <Object>
  16.      Standard object
2.查看Pod的状态
kubectl get pods
kubectl describe pods my-pod
3.监控Pod状态的变化
kubectl get pod -w
可以看到一个 namespace 中所有的 pod 的 phase 变化。
4.查看Pod的日志
kubectl logs my-pod
kubectl logs my-pod -c my-container
kubectl logs -f my-pod
kubectl logs -f my-pod -c my-container
5.交互式Debug
kubectl exec my-pod -it /bin/bash
kubectl top pod POD_NAME --containers
6.Pod的临终遗言
Pod的定义中通过.spec.containers[].terminationMessagePath指定在容器中的临终遗言日志文件的路径,默认值是/dev/termination-log.这个文件在Pod的整个生命周期内都会保存,每次新建一个Pod,都会在宿主机上创建一个文件,然后挂载到Pod的容器中,这些文件不会因为容器的销毁而丢失,所以容器可以把临终遗言写入这个文件,方便问题安排排错。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28624388/viewspace-2155913/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28624388/viewspace-2155913/

你可能感兴趣的:(kubernetes实践之五十三:Service中的故障排查)