#You will need 4 centos 7 servers for hosting a kubernetes cluster of 3 nodes and 1 master.

#Kubernetes main server is called a master server

#The worker nodes on which docker containers are deployed, are called Minions

#Kubernetes orchestrates docker containers on those minion servers. The docker+application combo that gets deployed on the minion servers are called the Pods.

#kubectl is the command line tool to do things in Kubernetes

#Out of the 4 servers mark one as the master server.

#Now on the master server do the following as root user:

yum -y install nano wget tree

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

yum -y install ntp

systemctl start ntpd

systemctl enable ntpd

yum -y install etcd kubernetes

#Then on the master server, open up /etc/etcd/etcd.conf

nano /etc/etcd/etcd.conf

#inside the master server etcd.conf file make sure the following is maintained:

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#Save and Close the file with Ctrl+X
#Then open up /etc/kubernetes/apiserver:

nano /etc/kubernetes/apiserver

#Make sure the following content is there inside the /etc/kubernetes/apiserver file

KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet_port=10250"
KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
KUBE_API_ARGS=""
#Save and Close the file with Ctrl+X
systemctl start etcd
systemctl enable etcd
systemctl start kube-apiserver
systemctl enable kube-apiserver
systemctl start kube-controller-manager
systemctl enable kube-controller-manager
systemctl start kube-scheduler
systemctl enable kube-scheduler
etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
#At this point you can run command “kubectl get nodes” which will output an empty set
#Then on one of the rest of the 3 servers: Lets call it Minion 1: Do as follows:

yum -y install nano wget tree

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

yum -y install ntp

systemctl start ntpd

systemctl enable ntpd

yum -y install flannel kubernetes
nano /etc/sysconfig/flanneld
# Make sure the content is compliant to as mentioned below
FLANNEL_ETCD="http://masterserverip:2379"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/config
# Make sure the content is compliant to as mentioned below
KUBE_MASTER="--master=http://masterserverip:8080"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/kubelet
# Make sure the content is compliant to as mentioned below
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=minion1ip"
KUBELET_API_SERVER="--api_servers=http://masterserverip:8080"
KUBELET_ARGS=""
#Save and Close the file with Ctrl+X
systemctl start kube-proxy
systemctl enable kube-proxy
systemctl start kubelet
systemctl enable kubelet
systemctl restart docker
systemctl enable docker
systemctl start flanneld
systemctl enable flanneld
#Then on one of the rest of the 2 servers: Lets call it Minion 2: Do as follows:

yum -y install nano wget tree

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

yum -y install ntp

systemctl start ntpd

systemctl enable ntpd

yum -y install flannel kubernetes
nano /etc/sysconfig/flanneld
# Make sure the content is compliant to as mentioned below
FLANNEL_ETCD="http://masterserverip:2379"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/config
# Make sure the content is compliant to as mentioned below
KUBE_MASTER="--master=http://masterserverip:8080"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/kubelet
# Make sure the content is compliant to as mentioned below
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=minion2ip"
KUBELET_API_SERVER="--api_servers=http://masterserverip:8080"
KUBELET_ARGS=""
#Save and Close the file with Ctrl+X
systemctl start kube-proxy
systemctl enable kube-proxy
systemctl start kubelet
systemctl enable kubelet
systemctl restart docker
systemctl enable docker
systemctl start flanneld
systemctl enable flanneld
#Then on the last server: Lets call it Minion 3: Do as follows:

yum -y install nano wget tree

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

yum -y install ntp

systemctl start ntpd

systemctl enable ntpd

yum -y install flannel kubernetes
nano /etc/sysconfig/flanneld
# Make sure the content is compliant to as mentioned below
FLANNEL_ETCD="http://masterserverip:2379"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/config
# Make sure the content is compliant to as mentioned below
KUBE_MASTER="--master=http://masterserverip:8080"
#Save and Close the file with Ctrl+X
nano /etc/kubernetes/kubelet
# Make sure the content is compliant to as mentioned below
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=minion3ip"
KUBELET_API_SERVER="--api_servers=http://masterserverip:8080"
KUBELET_ARGS=""
#Save and Close the file with Ctrl+X
systemctl start kube-proxy
systemctl enable kube-proxy
systemctl start kubelet
systemctl enable kubelet
systemctl restart docker
systemctl enable docker
systemctl start flanneld
systemctl enable flanneld
#Now go to master server and type
kubectl get nodes
# You should get 3 line output for 3 minions in the formatted table of NAME      LABELS       STATUS
In order to install GUI
yum install cockpit cockpit-kubernetes
systemctl enable cockpit.socket
systemctl start cockpit.socket


Note: In latest kubernetes, replication controllers are an obsolete idea and instead deployments and replication sets are used.
Leave a Reply