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 :
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.
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.:
If you already have this setup, make sure all the machines are able to talk to each other.
First things first,
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)
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.
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.
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:
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.
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.
3. Edit /etc/kubernetes/proxy:
No settings are required in this file. If you have set
KUBE_PROXY_ARGS, you can comment it out:
4. Start the Kubernetes nodes systemd services:
On each node, you need to start several services associated with a Kubernetes node:
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:
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