1
votes

i've a kubernetes cluster with a master node and 3 minions, i've already a glusterfs cluster, every node of kubernetes cluster have glusterfs-client installed and working. i'm trying to run a pod ( a simple mysql ) mounting /var/lib/mysql on glusterfs but i see:

Image: mysql:5.6 is ready, container is creating 

i run: kubectl get event i see:

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

if i run kubectl describe pod mysql-9ym10 i see:

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

this is the yaml file for container:

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

3 Answers

1
votes

i've got and endpoint that is configured with glusterfs ip addresses.

i know the posted link, i've followed it but the result is on my first post!

1
votes

On first: To use a GlusterFS you don't need to install glusterfs-client on kubernetes node. Kubernetes have the volume mounting option for glusterfs by default.

To use a glusterfs with kubernetes you need to things.

  1. a working glusterfs server. a running volume in the glusterfs server. I assume you have those. If anyone don't then create a glusterfs server and start your volumes with the following commands

    $ gluster volume create <volume-name> replica 2 transport tcp \
      peer1:/directory \
      peer2:/directory \
      force
    $ gluster volume start <vonlume-name>
    $ sudo gluster volume info
    
  2. if this is ok, you need an kubernetes endpoint to use with the pod. as far an example a end point is like this.

    kind: Endpoints
    apiVersion: v1
    metadata:
      name: glusterfs
    subsets:
    - addresses:
      - ip: peer1
      ports:
      - port: 1
    - addresses:
      - ip: peer2
      ports:
      - port: 1
    
  3. And at third mount the gfs volume to a pod with the end point.

          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
    

**The path must match the volume name with the glusterfs.

this all should work fine.

0
votes

You need to configure Endpoints https://github.com/kubernetes/kubernetes/blob/release-1.1/examples/glusterfs/README.md , otherwise kubernetes doesn't know how to access your gluster cluster.