Forum Navigation
You need to log in to create posts and topics.

Install Kubernetes on CentOS 7 / Redhat 7

Before starting make sure you configured permanent hostnames for the master and worker nodes this can be done editing /etc/hosts file or using command :

hostnamectl set-hostname master

and on the worker node

hostnamectl set-hostname workder1

Configure Kubernetes Repository – packages not available in the official Repos

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[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

Run installation commands

sudo yum install -y kubelet kubeadm kubectl

Enable and Start Service

systemctl enable kubelet
systemctl start kubelet

if firewald is running enable the following ports

sudo firewall-cmd –permanent –add-port=6443/tcp
sudo firewall-cmd –permanent –add-port=2379-2380/tcp
sudo firewall-cmd –permanent –add-port=10250/tcp
sudo firewall-cmd –permanent –add-port=10251/tcp
sudo firewall-cmd –permanent –add-port=10252/tcp
sudo firewall-cmd –permanent –add-port=10255/tcp
sudo firewall-cmd –reload

and for the worker nodes

sudo firewall-cmd –permanent –add-port=10251/tcp
sudo firewall-cmd –permanent –add-port=10255/tcp
firewall-cmd –reload

Disable selinux

sudo setenforce 0
sudo sed -i ‘s/^SELINUX=enforcing$/SELINUX=disabled/’ /etc/selinux/config

disable swap

sudo sed -i ‘/swap/d’ /etc/fstab
sudo swapoff -a

 

 

Initialize the kubernetes cluster

sudo kubeadm init

enable your user to administer the cluster

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

 

Join Worker node to the cluster ( the exact command will be printed once you finish creating the cluster)

kubeadm join 10.0.0.47:6443 –token f08041.ns5XXXXXXXXXXXXXXX \
–discovery-token-ca-cert-hash sha256:3d3e27XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX688d

 

 

Check Status of the kubernetes installation

Nodes Status

sudo kubectl get nodes

Pods Status

sudo kubectl get pods –all-namespaces

If you have found my website, guides, articles or videos useful, please buy me a coffee