我正在使用一个init容器创建一个Replication控制器。但是,初始化容器无法启动,并且容器的状态为:
NAME READY STATUS RESTARTS AGE
testcontainer 0/1 CrashLoopBackOff 12 37m
Run Code Online (Sandbox Code Playgroud)
我不确定哪一部分完全失败了,日志也无济于事。我的kubectl服务器版本为1.4(与客户端版本不同),因此我正在使用:
annotations:
pod.beta.kubernetes.io/init-containers:
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的复制控制器yaml文件。我正在使用“ hello-world”图像(而不是Nginx来使其更快)
apiVersion: v1
kind: ReplicationController
metadata:
name: testcontainer
spec:
replicas: 1
selector:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "install",
"image": "hello-world"
}
]'
spec:
containers:
- name: nginx
image: hello-world
dnsPolicy: Default
nodeName: x.x.x.x
Run Code Online (Sandbox Code Playgroud)
来自kubectl的日志描述了pod:
Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "nginx" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=nginx pod=testcontainer()"
32m 16s 145 {kubelet x.x.x.x} …Run Code Online (Sandbox Code Playgroud) kubernetes ×1