Kubernetes pod没有将卷绑定到容器

时间:2014-09-25 13:44:45

标签: docker kubernetes

我已经定义了以下ReplicationController JSON:

{
  "id": "PHPController",
  "kind": "ReplicationController",
  "apiVersion": "v1beta1",
  "desiredState": {
    "replicas": 2,
    "replicaSelector": {"name": "php"},
    "podTemplate": {
      "desiredState": {
         "manifest": {
           "version": "v1beta1",
           "id": "PHPController",
           "volumes": [{ "name": "wordpress", "path": "/mnt/nfs/wordpress_a", "hostDir": "/mnt/nfs/wordpress_a"}],
           "containers": [{
             "name": "php",
             "image": "internaluser/php53",
             "ports": [{"containerPort": 80, "hostPort": 9021}],
             "volumeMounts": [{"name": "wordpress", "mountPath": "/mnt/nfs/wordpress_a"}]
           }]
         }
       },
       "labels": {"name": "php"}
      }},
  "labels": {"name": "php"} 

}

使用“docker run -t -i -p 0.0.0.0:9021:80 -v / mnt / nfs / wordpress_a:/ mnt / nfs / wordpress_a:rw internaluser / php53”运行时,容器正确启动。

/ mnt / nfs / wordpress_a是一个NFS共享,安装在所有的minions上。每个minion都有完全的RW访问权限,我已经确认该共享存在。

使用Replication Controller创建pod容器后,我可以看到该卷实际上从未被绑定和/或未正确安装:

    "Volumes": {
        "/mnt/nfs/wordpress_a": "/var/lib/docker/vfs/dir/8b5dc8477958f5c1b894e68ab9412b41e81a34ef16dac81f0f9d4884352a90b7"
    },
    "VolumesRW": {
        "/mnt/nfs/wordpress_a": true
    }

    "HostConfig": {
        "Binds": null,
        "ContainerIDFile": "",
        "LxcConf": null,
        "Privileged": false,
        "PortBindings": {
            "80/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "9021"
                }
            ]
        },

我觉得奇怪的是容器认为/ mnt / nfs / wordpress_a映射到“/ var / lib / docker / vfs / dir / 8b5dc8477958f5c1b894e68ab9412b41e81a34ef16dac81f0f9d4884352a90b7”。

来自kubelet日志:

Desired [10.101.4.15]:[{Namespace:etcd Name:c823da9e-4437-11e4-a3b1-0050568421eb Manifest:{Version:v1beta1 ID:c823da9e-4437-11e4-a3b1-0050568421eb UUID:c823da9e-4437-11e4 -a3b1-0050568421eb卷:[{Name:wordpress来源:}]容器:[{Name:php Image:internaluser / php53命令:[] WorkingDir:Ports:[{Name:HostPort:9021 ContainerPort:80 Protocol:TCP HostIP: }] Env:[{Name:SERVICE_HOST Value:10.1.1.1}]内存:0 CPU:0 VolumeMounts:[{Name:wordpress ReadOnly:false MountPath:/ mnt / nfs / wordpress_a}] LivenessProbe:生命周期:特权:false} ] RestartPolicy:{Always:0xa99a20 OnFailure:Never:}}}}

有没有人有这方面的经验?我一直在疯狂排除故障。谢谢!

1 个答案:

答案 0 :(得分:2)