|
Kubernetes is an open source platform for managing containerized applications developed by Google. It allows you to manage, scale, and automatically deploy your containerized applications in the clustered environment. With Kubernetes, we can orchestrate our containers across multiple hosts, scale the containerized applications with all resources on the fly, and have centralized container management environment.
In this tutorial, I will show you step-by-step how to install and configure Kubernetes on CentOS 7. We will be using 1 server 'k8s-master' as the Kubernetes Host Master, and 2 servers as Kubernetes node, 'node01' and 'node02'.
Prerequisites
- 3 CentOS 7 Servers
- 10.0.15.10 k8s-master
- 10.0.15.21 node01
- 10.0.15.22 node02
- Root privileges
What we will do?
- Kubernetes Installation
- Kubernetes Cluster Initialization
- Adding node01 and node02 to the Cluster
- Testing - Create First Pod
Step 1 - Kubernetes Installation
In this first step, we will prepare those 3 servers for Kubernetes installation, so run all commands on the master and node servers.
We will prepare all servers for Kubernetes installation by changing the existing configuration on servers, and also installating some packages, including docker-ce and kubernetes itself.
- Configure Hosts
Edit hosts file on all server using the vim editor.
vim /etc/hosts
Paste the host's list below.
10.0.15.10 k8s-master
10.0.15.21 node01
10.0.15.22 node02
Save and exit.
- Disable SELinux
In this tutorial, we will not cover about SELinux configuration for Docker, so we will disable it.
Run the command below to disable SELinux.
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
- Enable br_netfilter Kernel Module
The br_netfilter module is required for kubernetes installation. Enable this kernel module so that the packets traversing the bridge are processed by iptables for filtering and for port forwarding, and the kubernetes pods across the cluster can communicate with each other.
Run the command below to enable the br_netfilter kernel module.
modprobe br_netfilter
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
- Disable SWAP
Disable SWAP for kubernetes installation by running the following commands.
swapoff -a
And then edit the '/etc/fstab' file.
vim /etc/fstab
Comment the swap line UUID as below.
- Install Docker CE
Install the latest version of Docker-ce from the docker repository.
Install the package dependencies for docker-ce.
yum install -y yum-utils device-mapper-persistent-data lvm2
Add the docker repository to the system and install docker-ce using the yum command.
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
Wait for the docker-ce installation.
- Install Kubernetes
Add the kubernetes repository to the centos 7 system by running the following command.
cat |
|