docker - Kubernetes pod 不断崩溃。使用相同的 docker 映像,我构建了运行良好的 docker 容器
问题描述
我刚刚开始研究 Kubernetes。
我的 pod 规格文件
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "test-cfg",
"labels": {
"app": "swelite"
}
},
"spec": {
"containers": [
{
"name": "config-agent",
"image": "img1",
"command": [
"/etc/init.d/docker-init"
],
"imagePullPolicy": "Never"
},
{
"name": "other-proc",
"image": "img2",
"command": [
"/etc/init.d/docker-init"
],
"imagePullPolicy": "Never"
}
]
}
}
我已经创建了两个带有 img1 和 img2 的 docker 容器,它们运行良好当我尝试使用这两个图像创建带有容器的 pod 时,它一直在崩溃
我在 pod 中容器的描述中得到了这个
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
我怀疑 pod 规格文件存在一些问题,因为如果我手动启动一个 docker 容器,图像就可以工作。
我也没有在日志中得到任何有用的信息。日志看起来不错。
kubectl 描述输出
[root@node1 abs]# kubectl describe pod test-cfg
Name: test-cfg
Namespace: default
Priority: 0
Node: node1/10.0.0.30
Start Time: Wed, 06 May 2020 12:04:12 +0000
Labels: app=swelite
Annotations: k8s.v1.cni.cncf.io/network-status:
[{
"name": "cni0",
"ips": [
"10.233.90.8"
],
"default": true,
"dns": {}
}]
k8s.v1.cni.cncf.io/networks-status:
[{
"name": "cni0",
"ips": [
"10.233.90.8"
],
"default": true,
"dns": {}
}]
kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"swelite"},"name":"test-cfg","namespace":"default"},"spec":{"...
Status: Running
IP: 10.233.90.8
IPs:
IP: 10.233.90.8
Containers:
config-agent:
Container ID: docker://dbd3ddf4c9f65fb0c97c30af3ab8e85da660e242b774be99f89e22b530a174e9
Image: img1
Image ID: docker://sha256:5eaaa7ee097877cb8b1628ed79f281006f01f39d8a30605d52dc40be5ae2da9f
Port: <none>
Host Port: <none>
Command:
/etc/init.d/docker-init
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Wed, 06 May 2020 12:10:47 +0000
Finished: Wed, 06 May 2020 12:11:30 +0000
Ready: False
Restart Count: 5
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-648ql (ro)
other-proc:
Container ID: docker://a6d4b63920b75e39fdbca37558cbbab23057d16fdb781144e51898f46b173aae
Image: img2
Image ID: docker://sha256:a33a6a51fb7a4398881c9ed0d201f03c490bb29581f7cb1c857edbd6cb7a5d48
Port: <none>
Host Port: <none>
Command:
/etc/init.d/docker-init
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Wed, 06 May 2020 12:10:48 +0000
Finished: Wed, 06 May 2020 12:11:31 +0000
Ready: False
Restart Count: 5
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-648ql (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-648ql:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-648ql
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned default/test-cfg to node1
Normal Pulled 6m19s (x3 over 8m) kubelet, node1 Container image "img1" already present on machine
Normal Created 6m19s (x3 over 8m) kubelet, node1 Created container config-agent
Normal Started 6m18s (x3 over 8m) kubelet, node1 Started container config-agent
Normal Pulled 6m18s (x3 over 8m) kubelet, node1 Container image "img2" already present on machine
Normal Created 6m18s (x3 over 7m59s) kubelet, node1 Created container other-proc
Normal Started 6m17s (x3 over 7m59s) kubelet, node1 Started container other-proc
Warning BackOff 5m34s (x3 over 6m31s) kubelet, node1 Back-off restarting failed container
Warning BackOff 3m (x10 over 6m31s) kubelet, node1 Back-off restarting failed container
我认为这可能会发生,因为我在 docker-init 脚本中的主要进程没有启动我在这里想要了解的是影响 pod 容器而不是 docker 容器的区别与资源利用有关吗?
解决方案
向我的 docker-init 脚本添加长时间睡眠后,该脚本不会退出并且我的容器不会重新启动。
推荐阅读
- ms-access - 关系窗口 - 如何从边缘显示表格?
- powerbi - 如何在 Power BI 上使用 DAX 在切片器上捕获选定的值?
- c# - Asp.NET MVC 中的更新
- javascript - 在 Wordpress 页面中嵌入 Javascript 和 PHO
- django - 找不到 Django、URL 和视图
- c# - xml linq。对象有问题。当前上下文中不存在该名称
- java - Google NLP api 给出 找不到 TLS ALPN 提供者;没有可用的 netty-tcnative、Conscrypt 或 Jetty NPN/ALPN
- python - 使用特殊字符绘图:“▬”
- node.js - Formdata 请求 ShortPixel API
- python - Tensorflow梯度返回null