Creating a Kubernetes Cluster

Install Docker and Kubernetes on All Servers

Nodes

Once we have logged in, we need to elevate privileges using sudo:

sudo su

Disable SELinux:

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

Enable the br_netfilter module for cluster communication:

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

Ensure that the Docker dependencies are satisfied:

yum install -y yum-utils device-mapper-persistent-data lvm2

Add the Docker repo and install Docker:

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 
yum install -y docker-ce

Set the cgroup driver for Docker to systemd, reload systemd, then enable and start Docker:

sed -i '/^ExecStart/ s/$/ --exec-opt native.cgroupdriver=systemd/' /usr/lib/systemd/system/docker.service
systemctl daemon-reload
systemctl enable docker --now

Add the Kubernetes repo:

Install Kubernetes v1.14.0:

Enable the kubelet service. The kubelet service will fail to start until the cluster is initialized, this is expected:

Master

Once we have logged in, we need to elevate privileges using sudo:

Disable SELinux:

Enable the br_netfilter module for cluster communication:

Ensure that the Docker dependencies are satisfied:

Add the Docker repo and install Docker:

Set the cgroup driver for Docker to systemd, reload systemd, then enable and start Docker:

Add the Kubernetes repo:

Install Kubernetes v1.14.0:

Enable the kubelet service. The kubelet service will fail to start until the cluster is initialized, this is expected:

Initialize the cluster using the IP range for Flannel:

Copy the kubeadmn join command that is in the output. We will need this later.

Nodes

Login back to the node and run the kubeadm command from master

Master

Exit sudo, copy the admin.conf to your home directory, and take ownership.

Deploy Flannel:

Check the cluster state:

Create and Scale a Deployment Using kubectl

Master

Create a simple deployment:

Inspect the pod:

Scale the deployment:

Inspect the pods. We should have four now:

Last updated