V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
winjohn
V2EX  ›  Kubernetes

k8s 创建 pod 问题,小白提问

  •  
  •   winjohn · 2018-04-12 11:31:14 +08:00 · 5777 次点击
    这是一个创建于 2423 天前的主题,其中的信息可能已经有所发展或是发生改变。

    个人需求是将 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

    6 条回复    2018-04-13 18:52:01 +08:00
    ifaii
        1
    ifaii  
       2018-04-12 12:16:47 +08:00 via iPhone
    centos 这个镜像又没有运行进程,当然就直接退出了
    winjohn
        2
    winjohn  
    OP
       2018-04-12 13:48:57 +08:00
    @ifaii 请问我该怎么修改配置才能让正常运行?是加环境变量 /bin/bash 吗?能否给个示例,谢谢。
    ifaii
        3
    ifaii  
       2018-04-12 14:35:35 +08:00
    插入一行 command,不让容器退出即可,比如
    spec:
    containers:
    command: ["tail"]
    winjohn
        4
    winjohn  
    OP
       2018-04-12 16:13:55 +08:00
    @ifaii 收到,非常感谢,已经搞定。
    winjohn
        5
    winjohn  
    OP
       2018-04-13 14:30:17 +08:00
    @ifaii 你好,再打扰下,请教个问题,我在 docker 中使用 insmod 命令去加载 ko 模块的时候为什么会报 Operation not permitted,是有什么限制还是需要我在装点什么东西呢?

    [root@2ba1f006d2ae rbd]# insmod rbd.ko
    insmod: ERROR: could not insert module rbd.ko: Operation not permitted
    ifaii
        6
    ifaii  
       2018-04-13 18:52:01 +08:00 via iPhone
    @winjohn 你的使用方式有错误,容器不是虚拟机,你可以理解为被隔离的进程,做这样的操作是不符合使用范式的,如果要安装应用,去写 Dockerfile,而不是在容器里面折腾
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   937 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 21:24 · PVG 05:24 · LAX 13:24 · JFK 16:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.