kubernetes - How to debug crash-looping pods in OpenShift?
问题描述
I have a simple DeploymentConfig:
apiVersion: v1
kind: DeploymentConfig
metadata:
name: my-dc
labels:
app: my
spec:
replicas: 3
template:
metadata:
labels:
app: my
spec:
containers:
- name: my
image: image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic
livenessProbe:
exec:
command:
- echo
- "I'm alive!"
initialDelaySeconds: 10
readinessProbe:
exec:
command:
- echo
- "I'm healthy!"
initialDelaySeconds: 15
periodSeconds: 15
The image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic
image stream points to my own image that is simply:
FROM registry.access.redhat.com/rhel7/rhel-atomic
When I do oc create -f my-dc.yaml
and try to check what is going on, I see that my pods are crash-looping.
To debug it, I did a oc status --suggest
. It suggests listing the container logs with oc logs my-dc-1-z889c -c my
. However, there is no logs for any of the containers.
My oc get events
does not help either. It just cycles through these messages:
<unknown> Normal Scheduled pod/my-dc-1-vnhmp Successfully assigned pc/my-dc-1-vnhmp to ip-10-0-128-37.ec2.internal
31m Normal Pulling pod/my-dc-1-vnhmp Pulling image "image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic"
31m Normal Pulled pod/my-dc-1-vnhmp Successfully pulled image "image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic"
31m Normal Created pod/my-dc-1-vnhmp Created container my
31m Normal Started pod/my-dc-1-vnhmp Started container my
27m Warning BackOff pod/my-dc-1-vnhmp Back-off restarting failed container
<unknown> Normal Scheduled pod/my-dc-1-z8jgb Successfully assigned pc/my-dc-1-z8jgb to ip-10-0-169-70.ec2.internal
31m Normal Pulling pod/my-dc-1-z8jgb Pulling image "image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic"
31m Normal Pulled pod/my-dc-1-z8jgb Successfully pulled image "image-registry.openshift-image-registry.svc:5000/pc/rhel-atomic"
31m Normal Created pod/my-dc-1-z8jgb Created container my
31m Normal Started pod/my-dc-1-z8jgb Started container my
27m Warning BackOff pod/my-dc-1-z8jgb Back-off restarting failed container
How do I debug this? Why the containers crash?
I am using OpenShift Online.
解决方案
似乎 pod 中的单个容器没有任何进程在运行。因此,容器在启动后立即终止。
保持容器运行的一个选项是将这些添加到容器的 DeploymentConfig 中:
command:
- /bin/sh
stdin: true
/bin/sh
根据图像中可用的内容,用不同的 shell(例如 bash)或从不同的位置替换。
推荐阅读
- aframe - 如何在 aframe v1.0.4+ 中以桌面模式启用游戏手柄?
- vb.net - 如何使用 VB.NET windows 服务检查应用程序是否正在运行并关闭或终止应用程序
- python - python Tronado不支持流式传输大量数据
- python - 使用flairNLP进行特征提取
- gradle - 如何使用 Gradle 打包 javafx 应用程序?
- javascript - React Navigation v5 如何使用打字稿在选项卡之间导航
- vue.js - 使用一种方法返回多个 vue 类
- android - 我们可以使用带有 WebRTC 的 Amazon Kinesis Video Streams 发送连接到 android 设备的硬件摄像头流吗?
- amazon-web-services - 您能否保证 AWS Batch 中的大量作业的订单?
- node.js - 如何构建 MongoDB v3.6 聚合调用(与 v3.4 相比)?