[GlusterFS Dynamic Provisioner] Online Resizing of GlusterFS PVs in kubernetes v>= 1.8 !!!

While the kubernetes storage-sig keeps adding new features in each and every release, we also listen to our user feedback to improve the existing storage interfaces in solving the existing limitations. Previously, the admin had to do proper capacity planning in order to use persistent Volumes as the microservices or the application pods wanted to …

Read more

“Retain” ( PV claim policy) GlusterFS Dynamically Provisioned Persistent Volumes in Kubernetes >=1.8

Since introduction, the dynamic provisioning feature of Kube storage defaulted with reclaim policy as Delete. It was not specific to glusterfs PVs rather common for all PVs which are dynamically provisioned in kube storage. However from kube >= v1.8, we could specify retain policy in storage class! A much-needed functionality in SC for different use …

Read more

[Gluster-Block] Provision Gluster Block Volumes In Kubernetes/Openshift – ( Part 1)

Voila…. Its almost a couple of years GlusterFS keep rocking in Container Storage Space which brought the buzz word “Container Native Storage” to the emerging market!! If you dont know about what I mean by “Container Native Storage” , check out this link GlusterFS was one of the plugin in kubernetes tree which implemented Dynamic …

Read more

[GlusterFS Dynamic Provisioner] Set GlusterFS Volume Options via StorageClass parameter

Much awaited RFE/Enhancement to the GlusterFS provisioner in Kubernetes !! Its been long time kubernetes/Openshift users are looking for a feature/functionality to enable various GlusterFS volume options via storage class. We discussed on few methods to implement this in Heketi. One thought was to wrap options under ‘classified’ strings, for eg# when someone asked for …

Read more

Support for “Volume Types” option in Kubernetes GlusterFS dynamic provisioner.

Till now, there was no option to specify various volume types and specifications of dynamically provisioned volumes in Kubernetes or Openshift. The main reason for that being we always recommend to have a ‘replica 3′ volume whenever it provision.

However there were requests from users of GlusterFS dynamic provisioner to have this functionality for various use cases, for example, someone want to setup a quick demo by having a replica 1 or replica 2 volume in a small cluster. Sometimes they want to create an EC volume via storage class…etc.

This functionality has been added some time back to Kubernetes upstream and provide the choice to select volume type in kubernetes/Openshift via Storage Class parameter.

This has been added in below format to the gluster plugins’ storage class.

volumetype : The volume type and it’s parameters can be configured with this optional value. If the volume type is not mentioned, it’s up to the provisioner to decide the volume type.

For example: ‘Replica volume’: volumetype: replicate:3 where ‘3’ is replica count.

‘Disperse/EC volume’: volumetype: disperse:4:2 where ‘4’ is data and ‘2’ is the redundancy count.

‘Distribute volume’: volumetype: none

Based on above mention, the volumes will be created in the trusted storage pool .

The storage class file will look like this:

apiVersion: storage.k8s.io/v1beta1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/glusterfs parameters: resturl: “http://127.0.0.1:8081” restuser: “admin” secretNamespace: “default” secretName: “heketi-secret” volumetype: “replicate:2”

Please let me know if you have any comments/suggestions/feedback about this functionality or if you would like to see any other enhancements to Gluster Dynamic Provisioner in Kubernetes/Openshift.

Why GlusterFS is contenarized ? Advantages ?

First of all GlusterFS is a userspace file system. Containers are designed for ‘user-space applications’ , Isn’t it? Once you containerize your user space application, you get many advantages, so GlusterFS containers.

If I quote the advantages of Container ( for ex: docker ) from this link:

Docker brings in an API for container management, an image format, and a possibility to use a remote registry for sharing containers. This scheme benefits both developers and system administrators with advantages such as:

Rapid application deployment – containers include the minimal runtime requirements of the application, reducing their size and allowing them to be deployed quickly.

Portability across machines – an application and all its dependencies can be bundled into a single container that is independent from the host version of Linux kernel, platform distribution, or deployment model. This container can be transferred to another machine that runs Docker and executed there without compatibility issues.

Version control and component reuse – you can track successive versions of a container, inspect differences, or roll-back to previous versions. Containers reuse components from the preceding layers, which makes them noticeably lightweight.

Sharing – you can use a remote repository to share your container with others. Red Hat provides a registry for this purpose, and it is also possible to configure your own private repository.

Lightweight footprint and minimal overhead – Docker images are typically very small, which facilitates rapid delivery and reduces the time to deploy new application containers.

Simplified maintenance – Docker reduces effort and risk of problems with application dependencies.

Apart from above, we closely work on Container Operating systems like “Atomic host” which designed as a container platform/OS to run your application containers, so GlusterFS can. It is not possible to use package managers like rpm and set up the system in your own way if you use this stripped container OSs. If we want to take advantage of these OSs, we have to be containerized.

If the application is in a container, we get many advantages which come with the container orchestration software like Kubernetes/Openshift. So, let Gluster take that advantage as well. For ex: if you deploy GlusterFS in a bare metal system there is no piece of code that monitors GlusterFS and if something goes wrong, admin intervention is required to bring it back, but if the gluster is containerized the orchestrator does it for you like any other application.

Let us look at the deployment part, if you have to deploy GlusterFS in a new Kubernetes/Openshift node, you don’t have to worry about the ‘preparation/setup’, ie Setting up the repositories, Installation of packages ..etc rather just label ( in case of DeamonSet deployment model in Kube/Openshift ) a node, You got new Gluster Node within seconds.

This list goes, but I have to stop.

I would like to wrap this article saying, the attempt of gluster containerization has been justified by the massive download of GlusterFS containers from docker hub.

https://hub.docker.com/r/gluster/gluster-centos/

Introducing “gluster-kubernetes” repo && “gk-deploy” script .

The information to bring Gluster into kubernetes was kind of scattered among few repos and we noticed few concerns on lagging single place to look into! it made the launch of new repo under gluster github account called “glusterfs-kubernetes” . This repo introduced a new tool called “gk-deploy” which helps to deploy the entire solution in kubernetes or Openshift environment.

An excerpt from its run.

[root@master deploy]# ./gk-deploy -g topology.json -n storagens Welcome to the deployment tool for GlusterFS on Kubernetes and OpenShift.

Before getting started, this script has some requirements of the execution environment and of the container platform that you should verify.

The client machine that will run this script must have: * Administrative access to an existing Kubernetes or OpenShift cluster * Access to a python interpreter ‘python’ * Access to the heketi client ‘heketi-cli’

Each of the nodes that will host GlusterFS must also have appropriate firewall
rules for the required GlusterFS ports:

* 2222 – sshd (if running GlusterFS in a pod) * 24007 – GlusterFS Daemon * 24008 – GlusterFS Management * 49152 to 49251 – Each brick for every volume on the host requires its own port. For every new brick, one new port will be used starting at 49152. We recommend a default range of 49152-49251 on each host, though you can adjust this to fit your needs.

In addition, for an OpenShift deployment you must:

* Have ‘cluster_admin’ role on the administrative account doing the deployment * Add the ‘default’ and ‘router’ Service Accounts to the ‘privileged’ SCC * Add the ‘heketi-service-account’ Service Account to the ‘privileged’ SCC * Have a router deployed that is configured to allow apps to access services running in the cluster

Do you wish to proceed with deployment?

[Y]es, [N]o? [Default: Y]: y Multiple CLI options detected. Please select a deployment option. [O]penShift, [K]ubernetes? [O/o/K/k]: o Using OpenShift CLI. NAME STATUS AGE storagens Active 25s Using namespace “storagens”. serviceaccount “heketi-service-account” created

…………

On a successful run, you will have running Gluster pods, Heketi service..etc.

Use iscsiadm session command to figure out details about a gluster block share.

Here is an easy way to list details about an ISCSI share or LUN. You have all the required details about the share below. You could also map this information in an iscsi client system to figure out the device map or device file as shown below.

[root@localhost glusterblock]# iscsiadm -m session -P 3 iSCSI Transport Class version 2.0-870 version 6.2.0.873-33 Target: iqn.2016-12.org.gluster-block:5b5b9581-bc66-4d51-8b4e-2befcd30fee7 (non-flash) Current Portal: 10.67.116.64:3260,1 Persistent Portal: 10.67.116.64:3260,1 ********** Interface: ********** Iface Name: default Iface Transport: tcp Iface Initiatorname: iqn.1994-05.com.redhat:8efc1ab116fc Iface IPaddress: 10.67.116.64 Iface HWaddress: Iface Netdev: SID: 41 iSCSI Connection State: LOGGED IN iSCSI Session State: LOGGED_IN Internal iscsid Session State: NO CHANGE ********* Timeouts: ********* Recovery Timeout: 120 Target Reset Timeout: 30 LUN Reset Timeout: 30 Abort Timeout: 15 ***** CHAP: ***** username: 5b5b9581-bc66-4d51-8b4e-2befcd30fee7 password: ******** username_in: password_in: ******** ************************ Negotiated iSCSI params: ************************ HeaderDigest: None DataDigest: None MaxRecvDataSegmentLength: 262144 MaxXmitDataSegmentLength: 262144 FirstBurstLength: 65536 MaxBurstLength: 262144 ImmediateData: Yes InitialR2T: Yes MaxOutstandingR2T: 1 ************************ Attached SCSI devices: ************************ Host Number: 3 State: running scsi3 Channel 00 Id 0 Lun: 0 Attached scsi disk sdb State: running [root@localhost glusterblock]# ll /dev/sdb brw-rw—- 1 root disk 8, 16 May 20 14:24 /dev/sdb [root@localhost glusterblock]# ll /dev/disk/by-path/ip-10.67.116.64:3260-iscsi-iqn.2016-12.org.gluster-block:5b5b9581-bc66-4d51-8b4e-2befcd30fee7-lun-0 lrwxrwxrwx 1 root root 9 May 20 14:24 /dev/disk/by-path/ip-10.67.116.64:3260-iscsi-iqn.2016-12.org.gluster-block:5b5b9581-bc66-4d51-8b4e-2befcd30fee7-lun-0 -> ../../sdb [root@localhost glusterblock]# iscsiadm -m session tcp: [41] 10.67.116.64:3260,1 iqn.2016-12.org.gluster-block:5b5b9581-bc66-4d51-8b4e-2befcd30fee7 (non-flash) [root@localhost glusterblock]#

Run Gluster systemd containers [without privileged mode] in Fedora/CentOS

Run Gluster systemd containers [without privileged mode] in Fedora/CentOS

Today we will discuss how to run gluster systemd containers without ‘privilege’ mode !! Awesome .. Isn’t it?

I owe this blog to few people latest being twitter.com/dglushenok/status/740265552258682882
Here is some details about my docker host setup:

Today we will discuss how to run gluster systemd containers without ‘privilege’ mode !! Awesome .. Isn’t it?

I owe this blog to few people latest being twitter.com/dglushenok/status/740265552258682882
Here is some details about my docker host setup:

[root@dhcp35-111 ~]# cat /etc/redhat-release Fedora release 24 (Twenty Four) [root@dhcp35-111 ~]# docker version Client: Version: 1.10.3 API version: 1.22 Package version: docker-1.10.3-21.git19b5791.fc24.x86_64 Go version: go1.6.2 Git commit: 19b5791/1.10.3 Built: OS/Arch: linux/amd64 Server: Version: 1.10.3 API version: 1.22 Package version: docker-1.10.3-21.git19b5791.fc24.x86_64 Go version: go1.6.2 Git commit: 19b5791/1.10.3 Built: OS/Arch: linux/amd64 [root@dhcp35-111 ~]#

I have pulled gluster/gluster-centos image from the docker hub and kept in my docker image registry.

[root@dhcp35-111 ~]# docker images |grep gluster docker.io/gluster/gluster-centos latest 759691b0beca 4 days ago 406.1 MB gluster/gluster-centos experiment fd8cd51f47fb 2 weeks ago 351.2 MB gluster/gluster-centos latest 9b46174d3366 3 weeks ago 351.1 MB gluster/gluster-centos gluster_3_7_centos_7 5809addca906 4 weeks ago 351.1 MB

The beauty is that we don’t need any extra steps to be performed in our host system.

NOTE: We haven’t submitted ‘privileged’ flag/option with below ‘docker run’ command. The volume mounts like ‘/etc/glusterfs’, ‘/var/lib/glusterd’, ‘/var/log/glusterfs’..etc are kept for glusterfs metadata and logs to be persistent across container spawning.

[root@dhcp35-111 docker-host]# docker run -d –name gluster3 -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs:z -v /sys/fs/cgroup:/sys/fs/cgroup:ro gluster/gluster-centos 8b1dd6f0aa88197bdcd022802f7c0c16d642630a21b2b43accfa5ed8023c197a [root@dhcp35-111 docker-host]#

As we now have the container id ( 8b1dd6f0aa88197bdcd022802f7c0c16d642630a21b2b43accfa5ed8023c197a), let’s get inside the container and examine the service and its behavior.

[root@dhcp35-111 docker-host]# docker exec -ti 8b1dd6f0aa88197bdcd022802f7c0c16d642630a21b2b43accfa5ed8023c197a /bin/bash [root@8b1dd6f0aa88 /]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 122764 4688 ? Ss 13:34 0:00 /usr/sbin/init root 22 0.0 0.0 36832 6348 ? Ss 13:34 0:00 /usr/lib/systemd/systemd-journald root 23 0.0 0.0 118492 2744 ? Ss 13:34 0:00 /usr/sbin/lvmetad -f root 29 0.0 0.0 24336 2884 ? Ss 13:34 0:00 /usr/sbin/crond -n rpc 42 0.0 0.0 64920 3244 ? Ss 13:34 0:00 /sbin/rpcbind -w root 44 0.0 0.2 430272 17300 ? Ssl 13:34 0:00 /usr/sbin/glusterd -p /var/run/glusterd.pid –log-level INFO root 68 0.0 0.0 82572 6212 ? Ss 13:34 0:00 /usr/sbin/sshd -D root 197 0.0 0.0 11788 2952 ? Ss 13:35 0:00 /bin/bash root 219 0.0 0.0 47436 3360 ? R+ 13:44 0:00 ps aux [root@8b1dd6f0aa88 /]# [root@8b1dd6f0aa88 /]# systemctl status glusterd ● glusterd.service – GlusterFS, a clustered file-system server Loaded: loaded (/usr/lib/systemd/system/glusterd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2016-06-28 13:34:53 UTC; 27s ago Process: 43 ExecStart=/usr/sbin/glusterd -p /var/run/glusterd.pid –log-level $LOG_LEVEL $GLUSTERD_OPTIONS (code=exited, status=0/SUCCESS) Main PID: 44 (glusterd) CGroup: /system.slice/docker-8b1dd6f0aa88197bdcd022802f7c0c16d642630a21b2b43accfa5ed8023c197a.scope/system.slice/glusterd.service └─44 /usr/sbin/glusterd -p /var/run/glusterd.pid –log-level INFO Jun 28 13:34:51 8b1dd6f0aa88 systemd[1]: Starting GlusterFS, a clustered file-system server… Jun 28 13:34:53 8b1dd6f0aa88 systemd[1]: Started GlusterFS, a clustered file-system server. Jun 28 13:35:15 8b1dd6f0aa88 systemd[1]: Started GlusterFS, a clustered file-system server. [root@8b1dd6f0aa88 /]# [root@8b1dd6f0aa88 /]# glusterd –version glusterfs 3.7.11 built on Apr 18 2016 13:20:46 Repository revision: git://git.gluster.com/glusterfs.git Copyright (c) 2006-2013 Red Hat, Inc. GlusterFS comes with ABSOLUTELY NO WARRANTY. It is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. [root@8b1dd6f0aa88 /]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@8b1dd6f0aa88 /]# rpm -qa |grep glusterfs glusterfs-3.7.11-1.el7.x86_64 glusterfs-fuse-3.7.11-1.el7.x86_64 glusterfs-cli-3.7.11-1.el7.x86_64 glusterfs-libs-3.7.11-1.el7.x86_64 glusterfs-client-xlators-3.7.11-1.el7.x86_64 glusterfs-api-3.7.11-1.el7.x86_64 glusterfs-server-3.7.11-1.el7.x86_64 glusterfs-geo-replication-3.7.11-1.el7.x86_64 [root@8b1dd6f0aa88 /]#

Let’s examine this container from docker host and verify these containers are running without privileged mode.

[root@dhcp35-111 docker-host]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8b1dd6f0aa88 gluster/gluster-centos “/usr/sbin/init” 6 minutes ago Up 6 minutes 111/tcp, 245/tcp, 443/tcp, 2049/tcp, 2222/tcp, 6010-6012/tcp, 8080/tcp, 24007/tcp, 38465-38466/tcp, 38468-38469/tcp, 49152-49154/tcp, 49156-49162/tcp gluster3 [root@dhcp35-111 docker-host]# docker inspect 8b1dd6f0aa88|grep -i privil “Privileged”: false, [root@dhcp35-111 docker-host]#

All is well, but what will be missing if you run these containers without ‘privilged’ mode? Not much! However, if you want to create gluster snapshots from the container we may need to export ‘/dev/’ to the container and operations to create devices from containers need privileged mode.

Persistent Volume and Claim in OpenShift and Kubernetes using GlusterFS Volume Plugin

[Update] There is a more advanced method of gluster volume provisioning available for kubernetes/openshift called dynamic volume provisioning as discussed here https://www.humblec.com/how-to-glusterfs-dynamic-volume-provisioner-in-kubernetes-v1-4-openshift/. However reading through this article is well encouraged to know what we had before dynamic volume provisioning and to know the method called static provisioning of volumes

.

.

OpenShift is a platform as a service product from Red Hat. The software that runs the service is open-sourced under the name OpenShift Origin, and is available on GitHub.

OpenShift v3 is a layered system designed to expose underlying Docker and Kubernetes concepts as accurately as possible, with a focus on easy composition of applications by a developer. For example, install Ruby, push code, and add MySQL.

Docker is an open platform for developing, shipping, and running applications. With Docker you can separate your applications from your infrastructure and treat your infrastructure like a managed application. Docker does this by combining kernel containerization features with workflows and tooling that help you manage and deploy your applications. Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. Available on GitHub.

Kubernetes is an open-source system for automating deployment, operations, and scaling of containerized applications. It groups containers that make up an application into logical units for easy management and discovery. Kubernetes builds upon a decade and a half of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community. Available on GitHub.

GlusterFS is a scalable network filesystem. Using common off-the-shelf hardware, you can create large, distributed storage solutions for media streaming, data analysis, and other data- and bandwidth-intensive tasks. GlusterFS is free and open source software. Available on GitHub.

Hope you know a little bit of all the above Technologies, now we jump right into our topic which is Persistent Volume and Persistent volume claim in Kubernetes and Openshift v3 using GlusterFS volume. So what is Persistent Volume? Why do we need it? How does it work using GlusterFS Volume Plugin?

In Kubernetes, Managing storage is a distinct problem from managing compute. The PersistentVolume subsystem provides an API for users and administrators that abstracts details of how storage is provided from how it is consumed. To do this we introduce two new API resources in kubernetes: PersistentVolume and PersistentVolumeClaim.

A PersistentVolume (PV) is a piece of networked storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g, can be mounted once read/write or many times read-only).

In simple words, Containers in Kubernetes Cluster need some storage which should be persistent even if the container goes down or no longer needed. So Kubernetes Administrator creates a Storage(GlusterFS storage, In this case) and creates a PV for that storage. When a Developer (Kubernetes cluster user) needs a Persistent Volume in a container, creates a Persistent Volume claim. Persistent Volume Claim will contain the options which Developer needs in the pods. So from list of Persistent Volume the best match is selected for the claim and Binded to the claim. Now the developer can use the claim in the pods.


Prerequisites:

Need a Kubernetes or Openshift cluster, My setup is one master and three nodes.

Note: you can use kubectl in place of oc, oc is openshift controller which is a wrapper around kubectl. I am not sure about the difference.

#oc get nodes NAME LABELS STATUS AGE dhcp42-144.example.com kubernetes.io/hostname=dhcp42-144.example.com,name=node3 Ready 15d dhcp42-235.example.com kubernetes.io/hostname=dhcp42-235.example.com,name=node1 Ready 15d dhcp43-174.example.com kubernetes.io/hostname=dhcp43-174.example.com,name=node2 Ready 15d dhcp43-183.example.com kubernetes.io/hostname=dhcp43-183.example.com,name=master Ready,SchedulingDisabled 15d

2) Have a GlusterFS cluster setup, Create a GlusterFS Volume and start the GlusterFS volume.

# gluster v status Status of volume: gluster_vol Gluster process TCP Port RDMA Port Online Pid —————————————————————————— Brick 170.22.42.84:/gluster_brick 49152 0 Y 8771 Brick 170.22.43.77:/gluster_brick 49152 0 Y 7443 NFS Server on localhost 2049 0 Y 7463 NFS Server on 170.22.42.84 2049 0 Y 8792 Task Status of Volume gluster_vol —————————————————————————— There are no active volume tasks

3) All nodes in kubernetes cluster must have GlusterFS-Client Package installed.

Now we have the prerequisites \o/ …

In Kube-master administrator has to write required yaml file which will be given as input to the kube cluster.

There are three files to be written by administrator and one by Developer.

Service
Service Keeps the endpoint to be persistent or active.
Endpoint
Endpoint is the file which points to the GlusterFS cluster location.
PV
PV is Persistent Volume where the administrator will define the gluster volume name, capacity of volume and access mode.
PVC
PVC is persistent volume claim where developer defines the type of storage as needed.

STEP 1: Create a service for the gluster volume.

# cat gluster_pod/gluster-service.yaml apiVersion: “v1” kind: “Service” metadata: name: “glusterfs-cluster” spec: ports: – port: 1 # oc create -f gluster_pod/gluster-service.yaml service “glusterfs-cluster” created

Verify:

# oc get service NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE glusterfs-cluster 172.30.251.13 1/TCP 9m kubernetes 172.30.0.1 443/TCP,53/UDP,53/TCP 16d

STEP 2: Create an Endpoint for the gluster service

# cat gluster_pod/gluster-endpoints.yaml apiVersion: v1 kind: Endpoints metadata: name: glusterfs-cluster subsets: – addresses: – ip: 170.22.43.77 ports: – port: 1

The ip here is the glusterfs cluster ip.

# oc create -f gluster_pod/gluster-endpoints.yaml endpoints “glusterfs-cluster” created # oc get endpoints NAME ENDPOINTS AGE glusterfs-cluster 170.22.43.77:1 3m kubernetes 170.22.43.183:8053,170.22.43.183:8443,170.22.43.183:8053 16d

STEP 3: Create a PV for the gluster volume.

# cat gluster_pod/gluster-pv.yaml apiVersion: “v1” kind: “PersistentVolume” metadata: name: “gluster-default-volume” spec: capacity: storage: “8Gi” accessModes: – “ReadWriteMany” glusterfs: endpoints: “glusterfs-cluster” path: “gluster_vol” readOnly: false persistentVolumeReclaimPolicy: “Recycle”

Note : path here is the gluster volume name. Access mode specifies the way to access the volume. Capacity has the storage size of the GlusterFS volume.

# oc create -f gluster_pod/gluster-pv.yaml persistentvolume “gluster-default-volume” created # oc get pv NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE gluster-default-volume 8Gi RWX Available 36s

STEP 4: Create a PVC for the gluster PV.

# cat gluster_pod/gluster-pvc.yaml apiVersion: “v1” kind: “PersistentVolumeClaim” metadata: name: “glusterfs-claim” spec: accessModes: – “ReadWriteMany” resources: requests: storage: “8Gi”

Note: the Developer request for 8 Gb of storage with access mode rwx.

# oc create -f gluster_pod/gluster-pvc.yaml persistentvolumeclaim “glusterfs-claim” created # oc get pvc NAME LABELS STATUS VOLUME CAPACITY ACCESSMODES AGE glusterfs-claim Bound gluster-default-volume 8Gi RWX 14s

Here the pvc is bounded as soon as created, because it found the PV that satisfies the requirement. Now lets go and check the pv status

# oc get pv NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE gluster-default-volume 8Gi RWX Bound default/glusterfs-claim 5m

See now the PV has been bound to “default/glusterfs-claim”. In this state developer has the Persistent Volume Claim bounded successfully, now the developer can use the pv claim like below.

STEP 5: Use the persistent Volume Claim in a Pod defined by the Developer.

# cat gluster_pod/gluster_pod.yaml kind: Pod apiVersion: v1 metadata: name: mypod spec: containers: – name: mygluster image: humble/gluster-client command: [“/usr/sbin/init”] volumeMounts: – mountPath: “/home” name: gluster-default-volume volumes: – name: gluster-default-volume persistentVolumeClaim: claimName: glusterfs-claim

The above pod definition will pull the humble/gluster-client image(some private image) and start init script. The gluster volume will be mounted on the host machine by the GlusterFS volume Plugin available in the kubernetes and then bind mounted to the container’s /home. So all the Kubernetes cluster nodes must have glusterfs-client packages.

Lets try running.

# oc create -f gluster_pod/fedora_pod.yaml pod “mypod” created # oc get pods NAME READY STATUS RESTARTS AGE mypod 1/1 Running 0 1m

Wow its running… lets go and check where it is running.

# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec57d62e3837 humble/gluster-client “/usr/sbin/init” 4 minutes ago Up 4 minutes k8s_myfedora.dc1f7d7a_mypod_default_5d301443-ec20-11e5-9076-5254002e937b_ed2eb8e5 1439dd72fb1d openshift3/ose-pod:v3.1.1.6 “/pod” 4 minutes ago Up 4 minutes k8s_POD.e071dbf6_mypod_default_5d301443-ec20-11e5-9076-5254002e937b_4d6a7afb

Found the Pod running successfully on one of the Kubernetes node.

On the host:

# df -h | grep gluster_vol 170.22.43.77:gluster_vol 35G 4.0G 31G 12% /var/lib/origin/openshift.local.volumes/pods/5d301443-ec20-11e5-9076-5254002e937b/volumes/kubernetes.io~glusterfs/gluster-default-volume

I can see the gluster volume being mounted on the host \o/. Lets check inside the container. Note the random number is the container-id from the docker ps command.

# docker exec -it ec57d62e3837 /bin/bash [root@mypod /]# df -h | grep gluster_vol 170.22.43.77:gluster_vol 35G 4.0G 31G 12% /home

Yippy the GlusterFS volume has been mounted inside the container on /home as mentioned in the pod definition. Lets try writing something to it

[root@mypod /]# mkdir /home/demo [root@mypod /]# ls /home/ demo

Since the AccessMode is RWX I am able to write to the mount point.

That’s all Folks.