k8s启动nginx容器错误CrashLoopBackOff
2022/1/28 7:06:15
本文主要是介绍k8s启动nginx容器错误CrashLoopBackOff,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
这里主要是因为是自己做的一个的一个nginx镜像(这里就不重复了)
~]# kubectl apply -f mynginx.yaml daemonset.apps/mynginx created
CrashLoopBackoff
~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mynginx-2qcvt 0/1 CrashLoopBackOff 5 (94s ago) 4m24s 10.244.1.24 vm-0-114-centos <none> <none> mynginx-drpq9 0/1 CrashLoopBackOff 5 (85s ago) 4m24s 10.244.2.32 vm-0-142-centos <none> <none># 查看报错 ~]# kubectl describe pods -n default mynginx-2qcvt ....... Warning BackOff 38s (x9 over 2m21s) kubelet Back-off restarting failed container ~]# kubectl logs -n default mynginx-2qcvt # 此时发现没有有用的报错 # 随便找一台节点的容器是否启动, ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 53d55b422a04 f276e0f4fb5b "/bin/bash" About a minute ago Exited (0) About a minute ago k8s_nginxcluster_mynginx-2qcvt_default_f1552f7b-85f2-42cb-9425-d5e4ae851075_6 # 这里发现是我的容器启动失败了,然后尝试手动启动 ~]# docker start 53d55b422a04 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 53d55b422a04 f276e0f4fb5b "/bin/bash" About a minute ago Exited (0) About a minute ago k8s_nginxcluster_mynginx-2qcvt_default_f1552f7b-85f2-42cb-9425-d5e4ae851075_6 # 发现还是没起来,这里突然想到nginx的启动会杀死他爹的,也就是system上帝京进程,然后我的yaml文件没有写启动命令,也就是默认启动,自然是失败的,所以这里再yaml文件中修改一下 ~]# vim mynginx.yaml --- kind: DaemonSet apiVersion: apps/v1 metadata: name: mynginx spec: selector: matchLabels: myapp: nginx template: metadata: labels: myapp: nginx spec: containers: - name: nginxcluster image: 172.17.0.98:5000/myos:nginx2 command: ["/data/nginx/sbin/nginx", "-g", "daemon off;"] # 增加一个启动命令 stdin: false tty: false ports: - protocol: TCP containerPort: 80 restartPolicy: Always ~]# kubectl apply -f mynginx.yaml daemonset.apps/mynginx configured ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mynginx-4qwl8 1/1 Running 0 3s 10.244.2.34 vm-0-142-centos <none> <none> mynginx-tzs48 1/1 Running 0 3s 10.244.1.26 vm-0-114-centos <none> <none> # 此时问题解决
这篇关于k8s启动nginx容器错误CrashLoopBackOff的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-23云原生周刊:利用 eBPF 增强 K8s
- 2024-12-20/kubernetes 1.32版本更新解读:新特性和变化一目了然
- 2024-12-19拒绝 Helm? 如何在 K8s 上部署 KRaft 模式 Kafka 集群?
- 2024-12-16云原生周刊:Kubernetes v1.32 正式发布
- 2024-12-13Kubernetes上运行Minecraft:打造开发者平台的例子
- 2024-12-12深入 Kubernetes 的健康奥秘:探针(Probe)究竟有多强?
- 2024-12-10运维实战:K8s 上的 Doris 高可用集群最佳实践
- 2024-12-022024年最好用的十大Kubernetes工具
- 2024-12-02OPA守门人:Kubernetes集群策略编写指南
- 2024-11-26云原生周刊:K8s 严重漏洞