无法在glusterfs上运行具有卷的容器

时间:2016-02-19 08:39:58

标签: docker kubernetes glusterfs

我是一个拥有主节点和3个小伙伴的kubernetes集群,我已经是一个glusterfs集群,kubernetes集群的每个节点都安装了glusterfs-client并正常工作。 我试图在glusterfs上运行一个pod(一个简单的mysql)挂载/ var / lib / mysql,但我看到了:

Image: mysql:5.6 is ready, container is creating 

我跑:     kubectl获得活动 我明白了:

Thu, 18 Feb 2016 10:08:01 +0100   Thu, 18 Feb 2016 10:08:01 +0100   1         mysql-9ym10         Pod                                 scheduled          {scheduler }                Successfully assigned mysql-9ym10 to nodeXX
Thu, 18 Feb 2016 10:08:01 +0100   Thu, 18 Feb 2016 10:08:01 +0100   1         mysql               ReplicationController               successfulCreate   {replication-controller }   Created pod: mysql-9ym10
Thu, 18 Feb 2016 10:08:02 +0100   Thu, 18 Feb 2016 10:08:12 +0100   2         mysql-9ym10         Pod                                 failedMount        {kubelet nodeXX}    Unable to mount volumes for pod "mysql-9ym10_default": exit status 1
Thu, 18 Feb 2016 10:08:02 +0100   Thu, 18 Feb 2016 10:08:12 +0100   2         mysql-9ym10         Pod                                 failedSync         {kubelet nodeXX}    Error syncing pod, skipping: exit status 1

如果我跑     kubectl描述pod mysql-9ym10 我明白了:

Name:                           mysql-9ym10
Namespace:                      default
Image(s):                       mysql:5.6
Node:                           nodeXX/nodeXX
Labels:                         app=mysql
Status:                         Pending
Reason:
Message:
IP:
Replication Controllers:        mysql (1/1 replicas created)
Containers:
  mysql:
    Image:              mysql:5.6
    State:              Waiting
      Reason:           Image: mysql:5.6 is ready, container is creating
    Ready:              False
    Restart Count:      0
Conditions:
  Type          Status
  Ready         False 
Events:
  FirstSeen                             LastSeen                        Count   From                            SubobjectPath   Reason          Message
  Thu, 18 Feb 2016 10:08:01 +0100       Thu, 18 Feb 2016 10:08:01 +0100 1       {scheduler }                                    scheduled       Successfully assigned mysql-9ym10 to nodeXX
  Thu, 18 Feb 2016 10:08:02 +0100       Thu, 18 Feb 2016 10:10:22 +0100 15      {kubelet nodeXX}                        failedMount     Unable to mount volumes for pod "mysql-9ym10_default": exit status 1
  Thu, 18 Feb 2016 10:08:02 +0100       Thu, 18 Feb 2016 10:10:22 +0100 15      {kubelet nodeXX}                        failedSync      Error syncing pod, skipping: exit status 1

这是容器的yaml文件:

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    app: mysql
  template:
    metadata:
      name: mysql
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:5.6
        ports:
        - containerPort: 3306
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: password
        volumeMounts:
          - mountPath: /var/lib/mysql
            name: glusterfsvol
      volumes:
      - glusterfs:
          endpoints: glusterfs-cluster
          path: glustervolume
          readOnly: false
        name: glusterfsvol

3 个答案:

答案 0 :(得分:1)

我已经获得了配置了glusterfs ip地址的端点。

我知道发布的链接,我已经关注了,但结果是我的第一篇文章!

答案 1 :(得分:1)

首先:要使用GlusterFS,您不需要在kubernetes节点上安装glusterfs-client。 Kubernetes默认为glusterfs提供卷安装选项。

要使用含有kubernetes的glusterfs,你需要做的事情。

  1. 一个正在运行的glusterfs服务器。 glusterfs服务器中的运行卷。我猜你有那些。如果有人不这样做,那么创建一个glusterfs服务器并使用以下命令启动您的卷

    EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false
    
  2. 如果可以,您需要一个kubernetes端点与pod一起使用。就目前的情况而言,终点就是这样。

    $ gluster volume create <volume-name> replica 2 transport tcp \
      peer1:/directory \
      peer2:/directory \
      force
    $ gluster volume start <vonlume-name>
    $ sudo gluster volume info
    
  3. 第三次将gfs卷安装到带有终点的pod。

    kind: Endpoints
    apiVersion: v1
    metadata:
      name: glusterfs
    subsets:
    - addresses:
      - ip: peer1
      ports:
      - port: 1
    - addresses:
      - ip: peer2
      ports:
      - port: 1
    
  4. **路径必须与卷名称匹配glusterfs。

    这一切都应该可以正常工作。

答案 2 :(得分:0)

您需要配置端点https://github.com/kubernetes/kubernetes/blob/release-1.1/examples/glusterfs/README.md,否则kubernetes不知道如何访问您的gluster群集。