Kubernetes multinode cluster deployment on Centos/Redhat 7.2/7.3

If you ever work with containerized applications in cluster environment then the much complicated task is to manage number of nodes over your complete infrastructure .

Kubernetes  is an opensource cluster management  system developed by Google which automates deployment , operations and scaling for containerized applications .

Note:   for container orchestration there are lots of tool in the market like

1.  Docker Swarm
2.  Google Kubernetes
3.  Rancher





component of kubernetes :

As given in above example there are two  main physical nodes in kubernetes

1. Kubernetes master
2. Kubernetes nodes

Important :   Inshort kubernetes is :



Internal architecture :

Kubernetes Master  architecture is pretty simple which can control one or more nodes .

Kubernetes  Master :    the controller of complete cluster can manage all the nodes where pods are spawned

kubernetes master components:


  1. kube-apiserver   :-->>  
  2. kube-scheduler
  3. kube-controller-manager

Kuberenetes  Nodes components:

  1.  kubelet
  2. kube-proxy
Important :   kubectl  is the command line interface can be placed any where even outside the cluster

kubectl  :     used by master to monitor the nodes and schedule the pods 
kube-proxy :   enable  software loadbalancing and services paradigm
kube-apiserver :   provides API  for kubernetes orchestration
kube-control-manager:  enforces kubernetes kubernetes services
kube-scheduler :   schedule containers on each hosts 

Etcd :    its a distributed set of key and value pair which store data persistently and accessible through the RESTful  API  

written in GO and uses RAFT consensus algorithm 

flannel :   It is virtual networking that gives a subnet to each hosts for use with containers during run time 





Setting up kubernetes cluster  


Master Node :  station107.example.com
Minion 1:    station108.example.com


Prequistes :

stop or manage firewall rules on each nodes

[root@station107 ~]# systemctl stop firewalld 
[root@station107 ~]# systemctl disable  firewalld 


Note:  make sure your dns is working fine and each node can reach eachothers by name and ip


Setting  up Master node :

Step 1:  Installing  all the required software

[root@station107 ~]# yum  install kubernetes kubernetes-nodes kubernetes-client  kubernetes-master etcd  docker docker-common docker-client

Important :  kubernetes works with docker not with docker-engine

Note:  flannel you don't need to install on master node because pods will not run on master nodes

Step 2:  configure kubernetes cluster configuration

i) configure etcd  file make these changes 


[root@station107 ~]# vim  /etc/etcd/etcd.conf

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://localhost:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"


ii)  configure kubernetes apiserver file 

[root@station107 ~]# vim  /etc/kubernetes/apiserver 


# The address on the local server to listen to.
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"

# The port on the local server to listen on.
KUBE_API_PORT="--port=8080"

# Port minions listen on
KUBELET_PORT="--kubelet-port=10250"

# Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://station107.example.com:2379"

# Address range to use for services  this ip leave this as it is
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"

# default admission control policies
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"

# Add your own!
KUBE_API_ARGS=""


iii)  this optional for master node 

[root@station107 ~]# vim  /etc/kubernetes/config 

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.10.107:8080"


iv)  Define flannel configure in etcd . This will be pulled by flannel service on the minions 

[root@station107 ~]# etcdctl  mk  /atomic.io/network/config  '{"Network":"172.17.0.0/16"}'


Step 3 :  Start  all the required services 

[root@station107 ~]# for  i  in  etcd kube-apiserver  kube-controller-manager kube-scheduler > do
> systemctl start  $i
> systemctl  enable  $i
> done

Now Setting up kubernetes  nodes  (minions)

Step 1:  Installing  all the required software


[root@station108 ~]# yum  install  flannel kubernetes  docker

Step 2:  making configuration file

i)  give path to load network from master 

[root@station108 ~]# vim  /etc/sysconfig/flanneld 
FLANNEL_ETCD="http://station107.example.com:2379"

ii)  How to connect with kubernetes master 

[root@station108 ~]# vim   /etc/kubernetes/config

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.10.107:8080"

iii) kubelet service on each minions 

[root@station108 ~]# vim   /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
# KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=station108.example.com"

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://192.168.10.107:8080"

# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

# Add your own!
KUBELET_ARGS=""


Step 3: starting all the services 

[root@station108 ~]# for  i  in  kube-proxy  kubelet docker flanneld 
> do
> systemctl  start  $i
> systemctl  enable  $i
> done



Now Go to Your Master Node and check for  minions 


[root@station107 ~]# kubectl get nodes
NAME                     STATUS    AGE
station108.example.com   Ready     2h


 Enjoy technology by Google 

Comments

Post a Comment