GlusterFS containers in Kubernetes Cluster for persistent data store !!

Everything is containerized, so Gluster . As you know, Gluster Container images are available for long time ( for both CentOS and Fedora ) in Docker hub. In previous blog posts, we saw how to build/run Gluster Containers. In this setup, we will try to set up a Kubernetes cluster with Gluster containers. If you dont know much about kubernetes , please go through this . In short, kubernetes is an orchestration software for container environment which brings the services like scheduling, service discovery..etc. We will deploy a kubernetes cluster in couple of atomic nodes. Then run Gluster containers on these atomic hosts via kubernetes. Once the gluster containers are running, we will form a trusted pool out of these gluster containers and export a volume, so that other application containers can make use of this volume to store its data in a persistent way!!.

Sounds interesting ? Yes, let us start.

NOTE: This article also discuss the steps to configure etcd server ( a key value store).
. For this particular setup we may not need to configure etcd. However your environment may need, for example to configure flannel.

Setup

Three centos ( You can also use fedora/RHEL) atomic hosts :

centos-atomic-KubeMaster centos-atomic-Kubenode1 centos-atomic-Kubenode2

To configure/install CentOS atomic hosts, please follow the steps mentioned here.
and the atomic images can be downloaded from here

Then start the atomic installation, if cloud init is configured, it will come into play and ask for “atomic host” login.

username: centos password: atomic

Note: The above is based on the cloud-init configuration. If you have customized the cloud-init configuration for different username and password, please supply the same. (wait till the vm to completely load meta-data and user-data. else it will throw invalid login till its completely loaded)

At this stage we have three atomic hosts.:

10.70.42.184 centos-atomic-KubeMaster 10.70.42.29 centos-atomic-Kubenode1 10.70.43.88 centos-atomic-Kubenode2

If you already have this setup, make sure all the machines are able to talk to each other.

First things first,

-bash-4.2# atomic host upgrade

Upgrade your system to latest docker, etcd, kubernetes..etc, in all nodes.
With the three systems in place, the next thing is to set up Kubernetes. Setting up Kubernetes on the Master, select any system to be master.

1. Etcd configuration:
Edit the /etc/etcd/etcd.conf. The etcd service needs to be configured to listen on all interfaces to ports 2380. (ETCD_LISTEN_PEER_URLS) and port 2379 (ETCD_LISTEN_CLIENT_URLS), and listen on 2380 on localhost (ETCD_LISTEN_PEER_URLS)

-bash-4.2# cat /etc/etcd/etcd.conf | grep -v “#” ETCD_NAME=default ETCD_DATA_DIR=”/var/lib/etcd/default.etcd” ETCD_LISTEN_PEER_URLS=”http://0.0.0.0:2380″ ETCD_LISTEN_CLIENT_URLS=”http://0.0.0.0:2379″ ETCD_ADVERTISE_CLIENT_URLS=”http://0.0.0.0:2379″


2. Kubernetes Configuration:

Edit the /etc/kubernetes/config file and change the KUBE_MASTER line to identify the location of your master server (it points to 127.0.0.1, by default). Leave other settings as they are.

KUBE_MASTER=”–master=http://10.70.42.184:8080″


3. Kubernetes apiserver Configuration:

Edit the /etc/kubernetes/apiserver and add a new KUBE_ETCD_SERVERS line (as shown below), then review and change other lines in the apiserver configuration file. Change KUBE_API_ADDRESS to listen on all network addresses(0.0.0.0), instead of just localhost. Set an address range for the KUBE_SERVICE_ADDRESS that Kubernetes can use to assign to services (see a description of this address below). Finally, remove the term “ServiceAccount” from the KUBE_ADMISSION_CONTROL instruction.

-bash-4.2# cat /etc/kubernetes/apiserver | grep -v “#” KUBE_API_ADDRESS=”–address=0.0.0.0″ KUBE_ETCD_SERVERS=”–etcd_servers=http://10.70.42.184:2379″ KUBE_SERVICE_ADDRESSES=”–service-cluster-ip-range=10.254.100.0/24″ KUBE_ADMISSION_CONTROL=”–admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota” KUBE_API_ARGS=””

4. Start master services:

To run the Kubernetes master services, you need to enable and start several systemd services. From the master, run the following for loop to start and enable Kubernetes systemd services on the master:

-bash-4.2# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done

5. Setting up Kubernetes on the Nodes

On each of the two Kubernetes nodes, you need to edit several configuration files and start and enable several Kubernetes systemd services:

1.Edit /etc/kubernetes/config:

Edit the KUBE_MASTER line in this file to identify the location of your master (it is 127.0.0.1, by default). allow_privileged must be set to true. Leave other settings as they are.

KUBE_ALLOW_PRIV=”–allow_privileged=true” KUBE_MASTER=”–master=http://10.70.42.184:8080″

2.Edit /etc/kubernetes/kubelet:

In this file on each node, modify KUBELET_ADDRESS (0.0.0.0 to listen on all network interfaces), KUBELET_HOSTNAME (replace hostname_override with the hostname or IP address of the local system). You may leave this blank to use the actual hostname, set KUBELET_ARGS, and KUBELET_API_SERVER as below. --host-network-sources=* is specified to use the host networking option of docker(–net=host). You can use any networking mode of docker. However in this setup, we use --net=host option to make sure we get maximum performance.

bash-4.2# cat /etc/kubernetes/kubelet | grep -v “#” KUBELET_ADDRESS=”–address=0.0.0.0″ KUBELET_HOSTNAME=”–hostname_override=” KUBELET_API_SERVER=”–api_servers=http://10.70.42.184:8080″ KUBELET_ARGS=”–register-node=true –host-network-sources=*”


3. Edit /etc/kubernetes/proxy:
No settings are required in this file. If you have set KUBE_PROXY_ARGS, you can comment it out:

bash-4.2# cat /etc/kubernetes/proxy ### # kubernetes proxy config # default config should be adequate # Add your own! #KUBE_PROXY_ARGS=”–master=http://master.example.com:8080″

4. Start the Kubernetes nodes systemd services:

On each node, you need to start several services associated with a Kubernetes node:

-bash-4.2# for SERVICES in docker kube-proxy.service kubelet.service; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done

5. Check the services:
Run the netstat command on each of the three systems to check which ports the services are running on. The etcd service should only be running on the master.

From master:

-bash-4.2# netstat -tulnp | grep -E “(kube)|(etcd)” tcp 0 0 127.0.0.1:10251 0.0.0.0:* LISTEN 17805/kube-schedule tcp 0 0 127.0.0.1:10252 0.0.0.0:* LISTEN 17764/kube-controll tcp6 0 0 :::6443 :::* LISTEN 17833/kube-apiserve tcp6 0 0 :::2379 :::* LISTEN 17668/etcd tcp6 0 0 :::2380 :::* LISTEN 17668/etcd tcp6 0 0 :::8080 :::* LISTEN 17833/kube-apiserve

From nodes:


-bash-4.2# netstat -tulnp | grep kube
tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 104398/kubelet
tcp 0 0 127.0.0.1:10249 0.0.0.0:* LISTEN 104331/kube-proxy
tcp6 0 0 :::10250 :::* LISTEN 104398/kubelet
tcp6 0 0 :::57421 :::* LISTEN 104331/kube-proxy
tcp6 0 0 :::10255 :::* LISTEN 104398/kubelet
tcp6 0 0 :::34269 :::* LISTEN 104331/kube-proxy
tcp6 0 0 :::58239 :::* LISTEN 104331/kube-proxy
tcp6 0 0 :::4194 :::* LISTEN 104398/kubelet

Read more

GlusterFS Bangalore Workshop

An introductory workshop on GlusterFS was held at Red Hat, Bangalore office (http://www.meetup.com/glusterfs-India/events/225770608/ ) on 31st October. Around 15 people turned up for the event. There were admins, DevOps and a few developers. As requested on the meetup page, the participants had turned up with their laptops to experience the awesomeness of Gluster!!

We started with a self-introduction. Then CentOS VM images containing pre-installed gluster packages were distributed. While the participants were deploying VM images, a brief introductory talk on GlusterFS was held. Prashanth Pai explained basic Gluster terminologies, various types of volumes, replication, geo-replication etc.

This was followed by a basic demo by Poornima which taught the participants to create a cluster, create different types of volumes, mount volumes etc.

Few participants were keen on using GlusterFS volumes over NFS and also in other cloud use-cases such as setting up GlusterFS + NFS HA cluster in AWS deployment. Further, Aravinda explained the advantages of using geo-replication for async replication.

The workshop was overall well received and we were glad to receive requests to conduct more GlusterFS Workshops!! You can read some feedback about this event here. Thanks to all speakers & attendees.

ps# If you would like to receive notifications about the upcoming GlusterFS meetups/workshops happening in India, join our meetup group http://www.meetup.com/glusterfs-India.

Gluster volume plugin of docker !!

Does gluster volume plugin available for docker?

Yes, its available here .

This article talks about how to use this plugin and make use of gluster volume when spawning docker containers.

For the gluster volume plugin to work, we need an experimental build of docker which can be fetched from docker Github. If you dont have the experimental binary of docker running in your system get it from docker Github.

https://github.com/docker/docker/tree/master/experimental have instructions on how to run docker experimental binary.

Once your docker daemon is running from the experimental build, pull gluster volume plugin from github source.

[root@dhcp35-20 go]# go get github.com/calavera/docker-volume-glusterfs

As mentioned in the README file in github, you need to execute ‘docker-volume-glusterfs’ as shown below. That said, here the IP, “10.70.1.100” is my gluster server which export a replica volume called ‘test-vol’. For more details on gluster volume types and configuration please refer http://gluster.readthedocs.org/en/latest/ .

[root@dhcp35-20 go]# docker-volume-glusterfs -servers 10.70.1.100
[root@dhcp35-20 check1]# ps aux |grep docker root 7674 0.0 0.0 7612 1596 pts/13 Sl+ 12:47 0:00 ./docker-volume-glusterfs -servers 10.70.1.100 root 8169 0.0 0.3 558828 29924 pts/14 Sl 12:52 0:00 ./docker-latest daemon

Once its done, we can spawn containers as shown below, where ‘test-vol’ is the gluster volume name and “/b1” is the mount point in spawned container, ‘docker.io/fedora’ is the image name.

‘touch /b1/second” create a file called ‘second’ in “/b1” mount point.

[root@]# ./docker-latest run -it –volume-driver glusterfs –volume test-vol:/b1 docker.io/fedora touch /b1/second

INFO[4891] POST /v1.21/containers/create INFO[4892] POST /v1.21/containers/b3b61146188db97e3b2c96e1ae38dc53478287d557e24a26b0dcbf09be68140a/attach?stderr=1&stdin=1&stdout=1&stream=1 INFO[4892] POST /v1.21/containers/b3b61146188db97e3b2c96e1ae38dc53478287d557e24a26b0dcbf09be68140a/start INFO[4892] POST /v1.21/containers/b3b61146188db97e3b2c96e1ae38dc53478287d557e24a26b0dcbf09be68140a/resize?h=46&w=190 INFO[4892] GET /v1.21/containers/b3b61146188db97e3b2c96e1ae38dc53478287d557e24a26b0dcbf09be68140a/json

Let us verify whether the file creation worked successfully and the new file (second) is available in the brick path of gluster server node.

From ‘test-vol’ volume details, we can see that “/home/test-brick1” is one leg of replica volume in my setup.

Volume Name: test-vol Type: Replicate Volume ID: 2cebb33f-e849-40c1-9344-939025f80b1f Status: Started Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: 10.70.1.100:/home/test-brick1 Brick2: 10.70.1.101:/home/test-brick2 Options Reconfigured: performance.readdir-ahead: on You have new mail in /var/spool/mail/root [root@dhcp1-100 test-brick1]#

[root@dhcp1-100 test-brick1]# pwd /home/test-brick1 [root@dhcp1-100 test-brick1]# ls second

Awesome !! Isn’t it?

Thanks https://github.com/calavera for the plugin & Thanks neependra for pointers.

Gluster 3.7 upgrade in EL systems.

If you are upgrading your Gluster 3.6 EL systems ( RHEL, SL..etc) to Gluster 3.7, you may come into package dependency issues.

For ex: in EL6 system:

error: Failed dependencies: pkgconfig(sqlite3) is needed by glusterfs-api-devel-3.7.0-1.el6.x86_64 pkgconfig(uuid) is needed by glusterfs-api-devel-3.7.0-1.el6.x86_64 python-argparse is needed by glusterfs-server-3.7.0-1.el6.x86_64 pyxattr is needed by glusterfs-server-3.7.0-1.el6.x86_64 liburcu-bp.so.1()(64bit) is needed by glusterfs-server-3.7.0-1.el6.x86_64 liburcu-cds.so.1()(64bit) is needed by glusterfs-server-3.7.0-1.el6.x86_64

The above-listed dependencies ( pyxattr, python-argparse, userspace-rcu..etc) are part of EPEL repo. You can enable EPEL repo in your system by executing the below command.

rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-${RHEL_VERSION}.noarch.rpm

NOTE: Replace ‘RHEL_VERSION’ with ‘5’,’6′, or ‘7’.

Once EPEL repo is enabled it will resolve the dependencies.

Building GlusterFS in a docker container

Although Setting up a glusterfs environment is a pretty simple and straightforward procedure, Gluster community do maintain docker images for gluster both in Fedora and CentOS in the docker hub for the ease of users. This blog is intended to walk the user through the steps of running GlusterFS with the help of docker.
The community maintains docker images GlusterFS release 3.6 in both Fedora-21 and CentOS-7. The following are the steps to build the GlusterFS docker images that we maintain:
To pull the docker image from the docker hub run the following command:
For GlusterFS-3.6 in Fedora-21

$ docker pull gluster/gluster-fedora

For GlusterFS-3.6 in CentOS-7

$ docker pull gluster/gluster-centos

This will fetch and build the docker image for you from the docker hub.
Alternatively, one could build the image from the Dockerfile directly. For this, one should pull the Gluster-Fedora Dockerfile from the source repository and build the image using that. For getting the source, One can make use of git:

$ git clone git@github.com:gluster/docker.git

This repository consists of Dockerfiles for GlusterFS built in both CentOS and Fedora distributions. Once you clone the repository, to build the image, run the following commands:
For Fedora,

$ docker build -t gluster-fedora docker/Fedora/Dockerfile

For CentOS,

$ docker build -t gluster-centos docker/CentOS/Dockerfile

This command will build the docker image from the Dockerfile you just cloned and will be assigned the name gluster-fedora or gluster-centos respectively. ‘-t’ option is used to give a name to the image we are about the build.
Once the image is built in either of the above two steps, we can now run the container with gluster daemon running. For this run the command:
Step 1:

$ docker run –privileged -d -p 22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro image name

( is either gluster-fedora or gluster-centos as per the configurations so far)
This is running container in detach mode, init script runs behind the screen.
Once docker returned the container id, you can get into the container via below command.

#docker exec -ti bash

Step2:

$docker run –privileged -p 22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro image name

In This mode it runs the init scripts in the container, you have to detach from this process.
To detach this container you can press Ctrl p + Ctrl q

Systemd has been installed and is running in the container we maintain. This is to ensure that gluster daemon is up and running by the time we boot up our container and also to deal with the “Failed to get D-Bus connection” issue. To fix the issue Dan Walsh’s blog on the same matter has been the only resource: developerblog.redhat.com/2014/05/05/running-systemd-within-docker-container/
For systemd to run without crashing it is necessary to run the container in the privileged mode since systemd requires CAP_SYS_ADMIN capability. As per the help of docker run shows, ‘-t’ option is given to allocate a pseudo-TTY and ‘-i’ stands for the interactive mode which keeps STDIN open even if not attached. The port 22 has been published to the host so that one can ssh into the container that will be running once this command is issued. In the docker file, the password for the root has been changed to ‘password’ for user to ssh into the running container.
One issued, this will boot up the Fedora or CentOS system and you have a container started with glusterd running in it. Now to login to the container, one need to inspect the IP of the container running. To get the ID of the container, one can do:

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d273cc739c9d gluster/gluster-fedora:latest “/usr/sbin/init” 3 minutes ago Up 3 minutes 49157/tcp, 49161/tcp, 49158/tcp, 38466/tcp, 8080/tcp, 2049/tcp, 24007/tcp, 49152/tcp, 49162/tcp, 49156/tcp, 6010/tcp, 111/tcp, 49154/tcp, 443/tcp, 49160/tcp, 38468/tcp, 49159/tcp, 245/tcp, 49153/tcp, 6012/tcp, 38469/tcp, 6011/tcp, 38465/tcp, 0.0.0.0:49153->22/tcp angry_morse

Note the Container ID of the image and inspect the image to get the IP address. Say the Container ID of the image is d273cc739c9d , so to get the IP do:

$ docker inspect d273cc739c9d
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“LinkLocalIPv6Address”: “fe80::42:acff:fe11:2”,
“LinkLocalIPv6PrefixLen”: 64,
The IP address is “172.17.0.2”
Once we have got the IP, ssh into the container:

$ ssh root@IP address
The password will be ‘password’ as specified in the dockerfile. Make sure the password is changed immediately.

[ ~]# ssh root@172.17.0.2
root@172.17.0.2's password:
System is booting up. See pam_nologin(8)
Last login: Mon May 4 06:22:34 2015 from 172.17.42.1
-bash-4.3# ps aux |grep glusterd
root 34 0.0 0.0 448092 15800 ? Ssl 06:01 0:00 /usr/sbin/glusterd -p /var/run/glusterd.pid
root 159 0.0 0.0 112992 2224 pts/0 S+ 06:22 0:00 grep --color=auto glusterd
-bash-4.3# gluster peer status
Number of Peers: 0
-bash-4.3# gluster --version
glusterfs 3.6.3 built on Apr 23 2015 16:12:34
Repository revision: git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc.
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
-bash-4.3#

Note:
If you want to keep the glusterfs configurations persistent then you have to create directories (/etc/glusterfs, /var/lib/glusterd, /var/log/glusterfs and appropriate bricks for the volume /brick1) and bind mount it to the container.
For example:

$ docker run --privileged -p 22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs image name

:z is to set the selinux label with the bind mount on the go.

That’s it!

Dockit: Gluster running in containers .. installed by dockit.

Widely adopted docker and GlusterFS has to be integrated. “GlusterFS is an open source, distributed filesystem capable of scaling to several petabytes and handling
thousands of clients. GlusterFS has functionalities like replication,
distribution, snapshot..etc by default. More details can be fetched from gluster.org.

WHAT IS DOCKIT:
Dockit is an application which is developed for:
Easy deployment of Containers from any docker image.
Easy deployment of GlusterFS containers with any version of GlusterFS binary
& auto configuration of GlusterFS Volumes.

If you would like to deploy GlusterFS in containers with specific version of gluster binary. Then it
is as easy as running below command in your system:

[root@HOST]dockit -pr humble -i f20glusterfssource -s -n 2 -g -t latest -gv -gi 3.5 -c configfile.

Let me explain above options, but you can see, ‘dockit –help’ already has information about
these options.
Pull an image called “f20glusterfssource”
with tag latest from docker repo‘humble’ and start 2
containers . Also work in gluster mode ( g)
and install 3.5 version of gluster binary ( –gi 3.5 )
inside these containers and auto configure gluster Volume (–gv) by fetching details from
configuration file called configfile .

Did you install docker packages in your system ?
Did you start docker daemon ?
Did you download the image from docker repository?
Did you create brick directories in your filesystem?
Did you run containers with exported bricks from host?
Did you install GlusterFS on these containers from gluster source ?
Did you configure a gluster Volume across these container nodes ?

Everything was taken care by “Dockit” !!
Apart from above,
Dockit can be used to build containers from Dockerfile and spawn containers using the
built image and it is also capable of pulling any image from docker repos. You can operate in
gluster mode on these containers as well.
Once dockit exported the volume , this volume can be used for virtual image store in any of the
virtualization technologies example ‘ovirt’ or any IaSS offerings example openstack . It can act
as an image store for cloud.
Active development going on to leverage its capabilities to multi host deployment. The docker
orchestration technologies will be soon integrated with dockit to make this possible.
More information on dockit can be fetched from:
https://github.com/humblec/dockit/.
https://www.humblec.com/.

Docker + GlusterFS = Dockit (An easy way of GlusterFS deployment with Docker)

As you know, docker and GlusterFS are widely adopted by IT world. The integration of glusterfs and docker technologies should be done without delay, so as to benefit from the fast paced advances in technology. For those who already know these terms Docker & GlusterFS , please skip below introduction , and start from “DOCKIT” …

Read more

Play with libgfapi and its python bindings..

What is libgfapi ? User-space library for accessing data in GlusterFS Filesystem-like API Runs in application process no FUSE, no copies, no context switches …but same volfiles, translators, etc. Could be used for Apache/nginx modules, MPI I/O (maybe), Ganesha, etc. ad infinitum BTW it’s usable from Python too 🙂 Yes, I copied it from http://rhsummit.files.wordpress.com/2013/06/darcy_th_1040_glusterfs.pdf …

Read more

Virtualization – Time Break – Glusterfs !

hmmm.. Its been long time I am writing articles in my space.. More than 50% were virtualization oriented .. Right now I am taking a break here and planning to come back with more Filesystem articles , obviously it will be centred on “glusterfs” where I am going to put my finger on. How-ever at …

Read more