欢迎光临
我们一直在努力

kubernetes如何实现Service中的故障排查

这篇文章主要为大家展示了“kubernetes如何实现Service中的故障排查”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“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的容器中,这些文件不会因为容器的销毁而丢失,所以容器可以把临终遗言写入这个文件,方便问题安排排错。

以上是“kubernetes如何实现Service中的故障排查”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注云行业资讯频道!

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。