top of page
Search

KUBERNETES INSTALLATION

KUBERNETES INSTALLATION ON CENTOS-8

-----------------------------------


Prerequisites:

--------------

It is recommended that your nodes should have at least 2 CPUs with 2GB RAM or more per machine.

NOTE: This is not a strict requirement but is largely driven by the needs of the application you intend to run.


All your nodes should also be able to connect to one another, either on a private or public network, whichever is available.

You will also need access to an account with sudo or root privileges.

br_netfilter module should be enabled on all machines.



LOGICAL ARCHITECTURE:

---------------------

Our installation is designed to have the Master-Node controlling the Worker Nodes. At the end of this installation, our logical architecture will look something like this.


Master Node – This machine generally acts as the control plane and runs the cluster database and the API server (which the kubectl CLI communicates with).


192.168.0.154 masterk8s masterk8s

192.168.0.195 workernode1 workernode1

192.168.0.152 workernode2 workernode2



SELINUX Disable:

--------------------


setenforce 0

# sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux


Add Port Numbers in Firewall

----------------------------

firewall-cmd --permanent --add-port=6443/tcp

firewall-cmd --permanent --add-port=2379-2380/tcp

firewall-cmd --permanent --add-port=10250/tcp

firewall-cmd --permanent --add-port=10251/tcp

firewall-cmd --permanent --add-port=10252/tcp

firewall-cmd --permanent --add-port=10255/tcp

firewall-cmd –reload

firewall-cmd --list-all


Install NETFILTER Module:

-------------------------

sudo modprobe br_netfilter


sudo echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables



2and Method:

------------


cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf

>net.bridge.bridge-nf-call-ip6tables = 1

>net.bridge.bridge-nf-call-iptables = 1

>EOF


# modprobe br_netfilter

# cat /proc/sys/net/bridge/bridge-nf-call-iptables

# sysctl --system


Swapoff:

--------


Swapoff -a



Docker Installation:

--------------------

#dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo


#dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm


# dnf erase podman buildah -y


#dnf install docker-ce --nobest -y


#usermod -aG docker $USER


# newgrp docker


INSTALLATION Docker-Compose:

----------------------------


# curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose


# chmod +x /usr/local/bin/docker-compose

# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

# docker version

# docker-compose version


# systemctl restart docker


# systemctl enable --now docker




Install Kubernetes:

-------------------

Execute the below commands on both master and worker nodes


cat <<EOF > /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch

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

exclude=kubelet kubeadm kubectl

EOF


Execute the below commands to install and start kubernetes service


#dnf upgrade -y

#dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

#systemctl enable kubelet

#systemctl start kubelet



Execute the below command only on master


kubeadm init --apiserver-advertise-address=10.128.0.2 --pod-network-cidr=192.168.0.0/16




{#exit

#mkdir -p $HOME/.kube

#sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

#sudo chown $(id -u):$(id -g) $HOME/.kube/config


kubeadm join 192.168.0.154:6443 --token t7e7ey.6hm027dit8iol4oq \

--discovery-token-ca-cert-hash sha256:29fbfa4105ef806be1560871b84afdddd5f5c107b43f4a3a69e173410fb187a8}



Deploy a POD network to the cluster. A Pod Network is a way for various nodes in a cluster to communicate with one another. Here, we’re using a calico network. Execute the below command in the Master node,

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml



OR


# wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml


# kubectl apply -f kube-flannel.yml


#kubectl get pod --all-namespaces


Execute the below command on master to check the node status


# kubectl get nodes


Note: If the nodes are not in READY state, then wait for some time and then execute the kubectl get nodes command again.




Trouble shooting:

-----------------


cat <<EOF | sudo tee /etc/docker/daemon.json

{

"exec-opts": ["native.cgroupdriver=systemd"],

"log-driver": "json-file",

"log-opts": {

"max-size": "100m"

},

"storage-driver": "overlay2"

}

EOF


#systemctl enable docker

#systemctl daemon-reload

#systemctl restart docker


Check if the kubelet became running:

#systemctl status kubelet








 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page