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

发布时间:2021-12-24 16:13:42 作者:小新
来源:亿速云 阅读:121

这篇文章主要为大家展示了“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中的故障排查”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. Kubernetes 控制器之 Service 讲解(七)
  2. Kubernetes中,通过Service访问Pod快速入门

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

service kubernetes

上一篇:kubernetes中如何实现Helm

下一篇:linux中如何删除用户组

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》