Gluster FS shared volumes for Kubernetes Cluster

March 14, 2019 854 views
Kubernetes CentOS

Hi,

Right now i am Testing DO Kubernetes and am starting to get my head around it.
There is only one thing that i am missing. An easy way to add shared volumes between PODS.

I tried GlusterFS since I am Familiar with it and Kubernetes has build in support for it, but so fare i Failed to get it working.

The GlusterFS is fine but I get an Error when I try to mound it.

"All subvolumes are down. Going offline until atleast one of them comes back up. The message "E [MSGID: 101075] [common-utils.c:294:gfresolveip6] 0-resolver: getaddrinfo failed (Name or service not known)"

I have read that Rook.io would be a alternative solution but am still hesitant.

Is there a way to use Gluster FS on DO Kubernetes ore are there any other solutions for my need Kind regards.

3 Answers
gradlon March 25, 2019
Accepted Answer

For all those of you wondering.
I found the Solution.
One caveat, the endpoint has to be in the same namespace as the pod Consuming it.

  1. Create a Service for Gluster

    ---
    apiVersion: v1
    kind: Service
    metadata:
    name: glusterfs-cluster
    namespace: global-storage
    spec:
    ports:
    - port: 1
    
  2. Create endpoint for your Service

    ---
    apiVersion: v1
    kind: Endpoints
    metadata:
    name: glusterfs-cluster
    namespace: default
    subsets:
    - addresses:
      - ip: 10.135.112.37
    ports:
      - port: 1
    - addresses:
      - ip: 10.135.53.65
    ports:
      - port: 1
    - addresses:
      - ip: 10.135.26.91
    ports:
      - port: 1
    
  3. Consume Shared Volume

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: nginx-deployment
    namespace: default
    labels:
    app: nginx
    spec:
    replicas: 1
    selector:
    matchLabels:
      app: nginx
    template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.15.4
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /usr/share/nginx/html
          name: nfs-vol
        - mountPath: /data
          name: glusterfsvol
      volumes:
      - name: nfs-vol
        nfs:
          server: glusterfs.cloud.integral-systems.ch
          path: /globalshare
      - name: glusterfsvol
        glusterfs:
          endpoints: glusterfs-cluster
          path: globalshare
          readOnly: false
    

Hope this helps :)

GlusterFS Native Storage Service for Kubernetes. gluster-kubernetes is a project to provide Kubernetes administrators a mechanism to easily deploy GlusterFS as a native storage service onto an existing Kubernetes cluster shareit apk.

@gradlon , Still its not working for me with the equivalent code (considering different namespace not default namespace) . Did you configure StorageClass or Init-Container in the Deployment level?
Pls let me know . Thanks in advance.

Have another answer? Share your knowledge.