个人需求是将 nfs 挂在到容器中使用,通过 yaml 配置的创建的 nginx pod 可以正常运行,于是将 nginx 的配置文件镜像改成了 centos,然后在运行的时候发生了 CrashLoopBackOff 状态,没有 logs 打印,yaml 配置如下
[root@k8s-master kubermange]# cat 002.yaml apiVersion: v1 kind: ReplicationController metadata: name: ct7 spec: replicas: 2 selector: app: web01 template: metadata: name: nginx labels: app: web01 spec: containers: - name: ct image: docker.io/centos ports: - containerPort: 22 volumeMounts: - mountPath: /mnt readOnly: false name: nginx-data volumes: - name: nginx-data nfs: server: 10.10.8.53 path: "/opt/xxx"
kubectl describe 看到的错误如下,还望各位大佬指导下哪里的问题,对 yaml 语法还不太了解,不清楚是不是语法有问题 Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message
24m 24m 1 {default-scheduler } Normal Scheduled Successfully assigned ct7-vq8q6 to k8s-node-2 24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id c2581b96d5e3; Security:[seccomp=unconfined] 24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id ac9f487f2e06; Security:[seccomp=unconfined] 24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id c2581b96d5e3 24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id ac9f487f2e06 24m 24m 2 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 10s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id a9a076866052 24m 24m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id a9a076866052; Security:[seccomp=unconfined] 24m 23m 2 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 20s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
23m 23m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id aca4a35df4a0 23m 23m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id aca4a35df4a0; Security:[seccomp=unconfined] 23m 23m 4 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 40s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
22m 22m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id 9ce5a4115e00; Security:[seccomp=unconfined] 22m 22m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id 9ce5a4115e00 22m 21m 6 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 1m20s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
21m 21m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id c195cd3416e8; Security:[seccomp=unconfined] 21m 21m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id c195cd3416e8 21m 18m 12 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 2m40s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
18m 18m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id 419f4cc8d420; Security:[seccomp=unconfined] 18m 18m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id 419f4cc8d420 13m 13m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id d121a921ab20; Security:[seccomp=unconfined] 13m 13m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id d121a921ab20 8m 8m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created Created container with docker id 7c5cc98fda79; Security:[seccomp=unconfined] 8m 8m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started Started container with docker id 7c5cc98fda79 24m 3m 10 {kubelet k8s-node-2} spec.containers{ct} Normal Pulling pulling image "docker.io/centos" 3m 3m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Started (events with common reason combined) 3m 3m 1 {kubelet k8s-node-2} spec.containers{ct} Normal Created (events with common reason combined) 24m 3m 11 {kubelet k8s-node-2} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy. 24m 3m 10 {kubelet k8s-node-2} spec.containers{ct} Normal Pulled Successfully pulled image "docker.io/centos" 18m 6s 87 {kubelet k8s-node-2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ct" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=ct pod=ct7-vq8q6_default(4eb85b50-3e05-11e8-a882-0050568a4944)"
24m 6s 113 {kubelet k8s-node-2} spec.containers{ct} Warning BackOff Back-off restarting failed docker container
附加图片说明 http://pic.caigoubao.cc/600509/yaml.png http://pic.caigoubao.cc/600509/error.png
1
ifaii 2018-04-12 12:16:47 +08:00 via iPhone
centos 这个镜像又没有运行进程,当然就直接退出了
|
3
ifaii 2018-04-12 14:35:35 +08:00
插入一行 command,不让容器退出即可,比如
spec: containers: command: ["tail"] |