记一次故障-Rancher界面突然无法访问,且K8s集群无法访问

公司使用docker单节点方式部署rancher,利用rancehr来操作k8s集群,有一天要访问rancher ui时,发现打不开,然后部署的所有容器也都不能使用,立马到服务器上查看情况,发现rancher容器还在,然后尝试进入容器时,报了错cannot exec in a stopped state: unknown,然后尝试查看rancher日志,发现可以查看

E0712 15:47:03.730752       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v3.ProjectCatalog: Get https://127.0.0.1:6443/apis/management.cattle.io/v3/watch/projectcatalogs?allowWatchBookmarks=true&resourceVersion=155367341&timeout=30m0s&timeoutSeconds=574: dial tcp 127.0.0.1:6443: connect: connection refused
E0712 15:47:03.730790       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v3.Catalog: Get https://127.0.0.1:6443/apis/management.cattle.io/v3/watch/catalogs?allowWatchBookmarks=true&resourceVersion=155367339&timeout=30m0s&timeoutSeconds=404: dial tcp 127.0.0.1:6443: connect: connection refused
E0712 15:47:02.947639       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v3.KontainerDriver: Get https://127.0.0.1:6443/apis/management.cattle.io/v3/watch/kontainerdrivers?allowWatchBookmarks=true&resourceVersion=155367345&timeout=30m0s&timeoutSeconds=481: dial tcp 127.0.0.1:6443: connect: connection refused
E0712 15:47:03.730823       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v3.Pipeline: Get https://127.0.0.1:6443/apis/project.cattle.io/v3/watch/pipelines?allowWatchBookmarks=true&resourceVersion=155367348&timeout=30m0s&timeoutSeconds=568: dial tcp 127.0.0.1:6443: connect: connection refused
E0712 15:47:03.730842       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v1.Namespace: Get https://127.0.0.1:6443/api/v1/watch/namespaces?allowWatchBookmarks=true&resourceVersion=155367325&timeout=30m0s&timeoutSeconds=449: dial tcp 127.0.0.1:6443: connect: connection refused
E0712 15:47:02.947667       6 reflector.go:307] github.com/rancher/norman/controller/generic_controller.go:229: Failed to watch *v3.RKEK8sSystemImage: Get https://127.0.0.1:6443/apis/management.cattle.io/v3/watch/rkek8ssystemimages?allowWatchBookmarks=true&resourceVersion=155367347&timeout=30m0s&timeoutSeconds=504: dial tcp 127.0.0.1:6443: connect: connection refused
2021/07/12 15:47:03 [FATAL] k3s exited with: exit status 255

通过日志发现,k3s exited with: exit status 255以及127.0.0.1:6443: connect: connection refused,因为6443是kube-apiserver所以估计应该是k8s集群的问题,然后查询了一下255这个状态,在githab上发现

文章地址:https://github.com/rancher/rancher/issues/22841

下面有一个回复(利用chrome浏览器自动翻译)


文章地址:https://github.com/rancher/rancher/issues/22841

以及另外一篇博文跟我的情况比较像


文章地址:https://forums.cnrancher.com/q_988.html

下面是一条回复

文章地址:https://forums.cnrancher.com/q_988.html

估计应该是k3s崩了,于是重启了一下对应机器,发现k3s正常运行了,但是rancher却没有启动,重启rancherdocker容器

docker resatrt rancher

发现443端口被占用

于是通过命令查找占用443端口的进程

netstat -tunlp|grep 443

发现是nginx占用了,但是这台机器并没有安装nginx,于是根据pid查看nginx所在位置

cd /proc/92922/cwd

发现有nginx配置,编辑nginx.conf发现有很多ingress-controller的配置,于是猜测这个nginxingress-controller容器的,于是查看ingress-controller的信息

docker inspect ingress_controller 
ingress_controller映射的端口

发现其确实占用了443端口,于是先停止ingress-controller,再启动rancher,再重启ingress_controller

docker stop ingress_controller
docker restart rancher
docker restart ingress_controller

问题解决

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言 目前来看kubespray没那么成熟(2019/03/19)。调研过很多部署工具,第三方得,官方得都试过。最...
    lzp1234阅读 12,227评论 2 6
  • 当我第一次开始我的Kubernetes之旅时,我一直在寻找一种设置本地部署环境的方式。很多人常常会使用miniku...
    RancherLabs阅读 4,531评论 0 2
  • 准备工作 准备一个k8s集群 建议所有节点提前导入rancher镜像,减少部署时间,以rancher 2.5.6为...
    行者深蓝阅读 10,083评论 0 4
  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 12,732评论 28 53
  • 信任包括信任自己和信任他人 很多时候,很多事情,失败、遗憾、错过,源于不自信,不信任他人 觉得自己做不成,别人做不...
    吴氵晃阅读 11,351评论 4 8