Search This Blog

Tuesday, 6 August 2019

Kubernetes basic installation and how to check cluster is running or not.

Kubernetes:
yum update -y

sestatus (status for selinux)
cat  /etc/sysconfig/selinux (disable selinux)
SELINUX = disable

systemctl disable firewalld (disable firewall)
yum remove chrony -y
yum install ntp -y
systemctl enable ntpd.service
systemctl start ntpd.service

/etc/hosts
master server(IP address)
node1 server (IP address)
node2 server (IP address)
validate the kubernetes master and nodes each other
ping master
ping node1
ping node2

On the Master Node following components will be installed
API Server         – It provides kubernetes API using Jason / Yaml over http, states of API objects are                                 stored in etcd
Scheduler          – It is a program on master node which performs the scheduling tasks like launching                                 containers in worker nodes based on resource availability
Controller Manager – Main Job of Controller manager is to monitor replication controllers and create                                     pods to maintain desired state.
etcd               – It is a Key value pair data base. It stores configuration data of cluster and cluster state.
Kubectl utility    – It is a command line utility which connects to API Server on port 6443. It is used                                 by administrators to create pods, services etc.

On Worker Nodes following components will be installed
Kubelet            – It is an agent which runs on every worker node, it connects to docker  and takes care                             of creating, starting, deleting containers.
Kube-Proxy     – It routes the traffic to appropriate containers based on ip address and port number                                 of the incoming request.
                            In other words we can say it is used for port translation.
Pod                  – Pod can be defined as a multi-tier or group of containers that are deployed on a                                    single worker node or docker host.


vim /etc/yum.repo.d/kubernetes
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
 
 
 
 yum install -y kubelet kubeadm  docker kubectl

 start docker kubelet
 systemctl start docker ;
 syatemctl enable docker;

 systemctl start kubelet;
 syatemctl enable kubelet;
 sysctl -p

kubadm init --pod-network-cidr=172.30.0.0/16

         After install it will show you to create folder just run those commands.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

 goto node1
 ssh to master
 docker images
 docker -ps

        To check cluster is running or not
kubectl get nodes
kubectl get pods (to check is any pods are running or not)
kubectl get pods --all-namespaces

goto gihub/flannel copy the link and paste it in master
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

kubectl get pods --all-namespaces
kubectl get nodes