【发布时间】:2023-03-16 21:25:01
【问题描述】:
如何调试为什么它的状态是CrashLoopBackOff?
我没有使用 minikube ,而是在 Aws Kubernetes 实例上工作。
我按照本教程进行操作。 https://github.com/mkjelland/spring-boot-postgres-on-k8s-sample
当我这样做时
kubectl create -f specs/spring-boot-app.yml
并通过
检查状态 kubectl get pods
它给了
spring-boot-postgres-sample-67f9cbc8c-qnkzg 0/1 CrashLoopBackOff 14 50m
下面的命令
kubectl describe pods spring-boot-postgres-sample-67f9cbc8c-qnkzg
给了
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning BackOff 3m18s (x350 over 78m) kubelet, ip-172-31-11-87 Back-off restarting failed container
命令 kubectl get pods --all-namespaces 给出
NAMESPACE NAME READY STATUS RESTARTS AGE
default constraintpod 1/1 Running 1 88d
default postgres-78f78bfbfc-72bgf 1/1 Running 0 109m
default rcsise-krbxg 1/1 Running 1 87d
default spring-boot-postgres-sample-667f87cf4c-858rx 0/1 CrashLoopBackOff 4 110s
default twocontainers 2/2 Running 479 89d
kube-system coredns-86c58d9df4-kr4zj 1/1 Running 1 89d
kube-system coredns-86c58d9df4-qqq2p 1/1 Running 1 89d
kube-system etcd-ip-172-31-6-149 1/1 Running 8 89d
kube-system kube-apiserver-ip-172-31-6-149 1/1 Running 1 89d
kube-system kube-controller-manager-ip-172-31-6-149 1/1 Running 1 89d
kube-system kube-flannel-ds-amd64-4h4x7 1/1 Running 1 89d
kube-system kube-flannel-ds-amd64-fcvf2 1/1 Running 1 89d
kube-system kube-proxy-5sgjb 1/1 Running 1 89d
kube-system kube-proxy-hd7tr 1/1 Running 1 89d
kube-system kube-scheduler-ip-172-31-6-149 1/1 Running 1 89d
命令 kubectl 记录 spring-boot-postgres-sample-667f87cf4c-858rx 不打印任何东西。
【问题讨论】:
-
你可以使用
kubectl describe pods spring-boot-postgres-sample-67f9cbc8c-qnkzg检查pods -
@ThanhNguyenVan 已编辑 ..我添加了事件 :.,你还想让我添加什么吗?
-
docker logs container_id显示属于该 pod 的容器日志 -
对不起,我不知道如何获取 container_id...我试过 kubectl logs
/jarName 但没有这样的容器 -
运行
kubectl describe pods spring-boot-postgres-sample-67f9cbc8c-qnkzg它显示容器所属。