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.

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.

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.

GlusterFS Containers with Docker, Kubernetes and Openshift

Thought of sharing consolidated news on GlusterFS containers efforts here. Below is the snip of the email which I sent a few days back to gluster-users and gluster-devel mailing list. I hope it gives a summary, if not please let me know.


I would like to provide you a status update on the developments with GlusterFS containers and its presence in projects like Docker, Kubernetes, and Openshift.

We have containerized GlusterFS with base image of CentOS and Fedora and its available at Docker Hub[1] to consume.

The Dockerfile of the image can be found at github[2].

You can pull the image with

# docker pull gluster/gluster-centos # docker pull gluster/gluster-fedora

The exact steps to be followed to run GlusterFS container is mentioned here[3].

We can deploy GlusterFS pods in Kubernetes Environment and an example blog about this setup can be found here [4].

There is GlusterFS volume plugin available in Kubernetes and openshift v3 which provides Persistent Volume
to the containers in the Environment, How to use GlusterFS containers for Persistent Volume and Persistent Volume Claim in Openshift has been recorded at [5].

[1]https://hub.docker.com/r/gluster/
[2]https://github.com/gluster/docker/
[3]http://tinyurl.com/jupgene
[4]http://tinyurl.com/zsrz36y
[5]http://tinyurl.com/hne8g7o

Please let us know if you have any comments/suggestions/feedback.

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.

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