Kubernetes 日常故障解决

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: Kubernetes 日常故障解决
+关注继续查看

Kubernetes 日常故障解决

image

问题 1:K8S 集群服务访问失败?


image


image


原因分析:证书不能被识别,其原因为:自定义证书,过期等。

解决方法:更新证书即可。

问题 2:K8S 集群服务访问失败?

curl: (7) Failed connect to 10.103.22.158:3000; Connection refused

原因分析:端口映射错误,服务正常工作,但不能提供服务。

解决方法:删除 svc,重新映射端口即可。

kubectl delete svc nginx-deployment

问题 3:K8S 集群服务暴露失败?

Error from server (AlreadyExists): services "nginx-deployment" already exists

原因分析:该容器已暴露服务了。

解决方法:删除 svc,重新映射端口即可。

问题 4:外网无法访问 K8S 集群提供的服务?

原因分析:K8S 集群的 type 为 ClusterIP,未将服务暴露至外网。


解决方法:修改 K8S 集群的 type 为 NodePort 即可,于是可通过所有 K8S 集群节点访问服务。

kubectl edit svc nginx-deployment

问题 5:pod 状态为 ErrImagePull?

readiness-httpget-pod   0/1     ErrImagePull   0          10s


image


原因分析:image 无法拉取;


image


image


解决方法:更换镜像即可。

问题 6:创建 init C 容器后,其状态不正常?

NAME READY STATUS RESTARTS AGEmyapp-pod 0/1 Init:0/2 0 20s

原因分析:查看日志发现,pod 一直出于初始化中;然后查看 pod 详细信息,定位 pod


创建失败的原因为:初始化容器未执行完毕。

Error from server (BadRequest): container "myapp-container" in pod "myapp-pod" is waiting to start: PodInitializing


image


image


image


waiting for myservice
Server: 10.96.0.10Address: 10.96.0.10:53
** server can't find myservice.default.svc.cluster.local: NXDOMAIN
*** Can't find myservice.svc.cluster.local: No answer*** Can't find myservice.cluster.local: No answer*** Can't find myservice.default.svc.cluster.local: No answer*** Can't find myservice.svc.cluster.local: No answer*** Can't find myservice.cluster.local: No answer

解决方法:创建相关 service,将 SVC 的 name 写入 K8S 集群的 coreDNS 服务器中,于是


coreDNS 就能对 POD 的 initC 容器执行过程中的域名解析了。

kubectl apply -f myservice.yaml


image


image


image


NAME READY STATUS RESTARTS AGE
myapp-pod 0/1 Init:1/2 0 27mmyapp-pod 0/1 PodInitializing 0 28mmyapp-pod 1/1 Running 0 28m


image


问题 7:探测存活 pod 状态为 CrashLoopBackOff?

原因分析:镜像问题,导致容器重启失败。


解决方法:更换镜像即可。


image


image


问题 8:POD 创建失败?

readiness-httpget-pod 0/1 Pending 0 0sreadiness-httpget-pod 0/1 Pending 0 0sreadiness-httpget-pod 0/1 ContainerCreating 0 0sreadiness-httpget-pod 0/1 Error 0 2sreadiness-httpget-pod 0/1 Error 1 3sreadiness-httpget-pod 0/1 CrashLoopBackOff 1 4sreadiness-httpget-pod 0/1 Error 2 15sreadiness-httpget-pod 0/1 CrashLoopBackOff 2 26sreadiness-httpget-pod 0/1 Error 3 37sreadiness-httpget-pod 0/1 CrashLoopBackOff 3 52sreadiness-httpget-pod 0/1 Error 4 82s

原因分析:镜像问题导致容器无法启动。


image


解决方法:更换镜像。


image


image


问题 9:POD 的 ready 状态未进入?

readiness-httpget-pod   0/1     Running   0          116s


原因分析:POD 的执行命令失败,无法获取资源。


image


解决方法:进入容器内部,创建 yaml 定义的资源


image


image


问题 10:pod 创建失败?


image


原因分析:yml 文件内容出错—-使用中文字符;

解决方法:修改 myregistrykey 内容即可。


image


11、kube-flannel-ds-amd64-ndsf7 插件 pod 的 status 为 Init:0/1?


image


排查思路:kubectl -n kube-system describe pod kube-flannel-ds-amd64-ndsf7 #查询 pod 描述信息;


image


原因分析:k8s-slave1 节点拉取镜像失败。


解决方法:登录 k8s-slave1,重启 docker 服务,手动拉取镜像。


image


k8s-master 节点,重新安装插件即可。

kubectl create -f kube-flannel.yml;kubectl get nodes


image


12、K8S 创建服务 status 为 ErrImagePull?


image


排查思路:

kubectl describe pod test-nginx


image


原因分析:拉取镜像名称问题。

解决方法:删除错误 pod;重新拉取镜像;

kubectl delete pod test-nginx;kubectl run test-nginx --image=10.0.0.81:5000/nginx:alpine

13、不能进入指定容器内部?


image


原因分析:yml 文件 comtainers 字段重复,导致该 pod 没有该容器。

解决方法:去掉 yml 文件中多余的 containers 字段,重新生成 pod。


image


image


14、创建 PV 失败?


image


原因分析:pv 的 name 字段重复。

解决方法:修改 pv 的 name 字段即可。


image


15、pod 无法挂载 PVC?


image


image


原因分析:pod 无法挂载 PVC。


image


image


accessModes 与可使用的 PV 不一致,导致无法挂载 PVC,由于只能挂载大于 1G 且 accessModes 为 RWO 的 PV,故只能成功创建 1 个 pod,第 2 个 pod 一致 pending,按序创建时则第 3 个 pod 一直未被创建;


解决方法:修改 yml 文件中 accessModes 或 PV 的 accessModes 即可。


image


16、问题:pod 使用 PV 后,无法访问其内容?


image


原因分析:nfs 卷中没有文件或权限不对。


image


image


解决方法:在 nfs 卷中创建文件并授予权限。


image


image


17、查看节点状态失败?

Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)

原因分析:没有 heapster 服务。

解决方法:安装 promethus 监控组件即可。


image


image


18、pod 一直处于 pending’状态?


image


原因分析:由于已使用同样镜像发布了 pod,导致无节点可调度。


image


解决方法:删除所有 pod 后部署 pod 即可。


image


19、helm 安装组件失败?

[root@k8s-master01 hello-world]# helm install
Error: This command needs 1 argument: chart nam
[root@k8s-master01 hello-world]# helm install ./Error: no Chart.yaml exists in directory "/root/hello-world"

原因分析:文件名格式不对。


解决方法:mv chart.yaml Chart.yaml


image



相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
云原生实践公开课
课程大纲 开篇:如何学习并实践云原生技术 基础篇: 5 步上手 Kubernetes 进阶篇:生产环境下的 K8s 实践 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
相关文章
|
2月前
|
运维 Kubernetes Shell
Kubernetes —集群故障排查(Kubectl 、telepresence)
Kubernetes —集群故障排查(Kubectl 、telepresence)
32 2
|
2月前
|
JSON 运维 Kubernetes
Kubernetes集群故障排查—使用 crictl 对 Kubernetes 节点进行调试
Kubernetes集群故障排查—使用 crictl 对 Kubernetes 节点进行调试
30 0
|
2月前
|
运维 Kubernetes 网络安全
|
5月前
|
存储 Kubernetes 网络协议
安装Kubernetes集群
安装Kubernetes集群
212 0
|
7月前
|
Kubernetes Docker Perl
记一次kubernetes故障
记一次kubernetes故障
94 0
|
11月前
|
资源调度 Kubernetes 负载均衡
玩转Kubernetes—使用minikube操作集群(下)
玩转Kubernetes—使用minikube操作集群
|
11月前
|
存储 Kubernetes 调度
玩转Kubernetes—使用minikube操作集群(上)
玩转Kubernetes—使用minikube操作集群
|
12月前
|
canal Kubernetes 安全
使用kubeadm从0到1搭建kubernete集群
使用kubeadm从0到1搭建kubernete集群
437 0
使用kubeadm从0到1搭建kubernete集群
|
弹性计算 Kubernetes 监控
Kubernetes 集群故障案例
Kubernetes 集群故障案例
236 1
|
Kubernetes Linux 网络安全
Kubernetes安装篇(下):基于Kubeadm方式的集群部署
在实际生产环境中,Kubernetes 环境就比这复杂的多,起码也是集群起步,因此,本文将从生产环境出发,为你带来基于生产环境下的 Kubernetes 集群部署,让你真正懂得该如何部署真正的 Kubernetes 集群环境。
631 0
推荐文章
更多