Skip to content

Latest commit

 

History

History
118 lines (110 loc) · 3.06 KB

Kubernetes-Installation.MD

File metadata and controls

118 lines (110 loc) · 3.06 KB

Kubernetes Cluster installation using kubeadm

Follow this documentation to set up a Kubernetes cluster on CentOS 7 Virtual machines.

This documentation guides you in setting up a cluster with one master node and two worker nodes.

Master: t2.medium Worker Nodes: t2.micro

Ports require for kubernetes master

6443
32750
10250
4443
443
8080
179 --> Should be allowed for Master and Worker nodes. 

On both Kmaster and Kworker Nodes

Perform all the commands as root user unless otherwise specified

Install, enable and start docker service

Use the Docker repository to install docker.

If you use docker from CentOS OS repository, the docker version might be old to work with Kubernetes v1.13.0 and above

```sh
yum install -y -q yum-utils device-mapper-persistent-data lvm2 > /dev/null 2>&1
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo > /dev/null 2>&1
yum install -y -q docker-ce >/dev/null 2>&1
systemctl enable docker
systemctl start docker
Disable SELinux
setenforce 0
sed -i --follow-symlinks 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
Disable Firewall
systemctl disable firewalld
systemctl stop firewalld
Disable swap
sed -i '/swap/d' /etc/fstab
swapoff -a
Update sysctl settings for Kubernetes networking
cat >>/etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

Kubernetes Setup

Add yum repository
cat >>/etc/yum.repos.d/kubernetes.repo<<EOF
[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
EOF
Install Kubernetes
yum install -y kubeadm-1.15.6-0.x86_64 kubelet-1.15.6-0.x86_64 kubectl-1.15.6-0.x86_64
Enable and Start kubelet service
systemctl enable kubelet
systemctl start kubelet

On kmaster

Initialize Kubernetes Cluster
kubeadm init --apiserver-advertise-address=<MasterServerIP> --pod-network-cidr=192.168.0.0/16
Copy kube config

To be able to use kubectl command to connect and interact with the cluster, the user needs kube config file.

In my case, the user account is praveen

mkdir /home/praveen/.kube
cp /etc/kubernetes/admin.conf /home/praveen/.kube/config
chown -R praveen:praveen /home/praveen/.kube
Deploy Calico network

This has to be done as the user in the above step (in my case it is praveen)

kubectl create -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml
Cluster join command
kubeadm token create --print-join-command

On Kworker

Join the cluster

Use the output from kubeadm token create command in previous step from the master server and run here.

Verifying the cluster

Get Nodes status
kubectl get nodes
Get component status
kubectl get cs