1

我有一个带有主节点和 3 个仆从的 kubernetes 集群,我已经有一个 glusterfs 集群,kubernetes 集群的每个节点都安装了 glusterfs-client 并且可以正常工作。我正在尝试在 glusterfs 上运行挂载 /var/lib/mysql 的 pod(一个简单的 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 describe 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
4

3 回答 3

1

我有一个配置了 glusterfs ip 地址的端点。

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

于 2016-02-21T11:29:36.533 回答
1

首先:要使用 GlusterFS,您不需要在 kubernetes 节点上安装 Glusterfs-client。Kubernetes 默认有 glusterfs 的卷挂载选项。

要将 glusterfs 与 kubernetes 一起使用,您需要做一些事情。

  1. 一个工作的 glusterfs 服务器。glusterfs 服务器中正在运行的卷。我假设你有那些。如果有人不创建一个 glusterfs 服务器并使用以下命令启动您的卷

    $ gluster volume create <volume-name> replica 2 transport tcp \
      peer1:/directory \
      peer2:/directory \
      force
    $ gluster volume start <vonlume-name>
    $ sudo gluster volume info
    
  2. 如果没问题,您需要一个 Kubernetes 端点来与 pod 一起使用。就一个例子而言,端点是这样的。

    kind: Endpoints
    apiVersion: v1
    metadata:
      name: glusterfs
    subsets:
    - addresses:
      - ip: peer1
      ports:
      - port: 1
    - addresses:
      - ip: peer2
      ports:
      - port: 1
    
  3. 并在第三次将 gfs 卷安装到具有端点的 pod 上。

          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: <volume-name>
             name: glusterfsvol
    

**路径必须与 glusterfs 的卷名匹配。

这一切都应该正常工作。

于 2016-02-25T09:57:45.943 回答
0

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

于 2016-02-21T10:43:19.670 回答