SETTING UP A SINGLE-NODE KUBERNETES CLUSTER ON AWS
KUBERNETES FUNDAMENTALS
DEPLOYING A SINGLE-NODE KUBERNETES CLUSTER ON AWS
A COMPREHENSIVE GUIDE
Introduction
To accommodate Docker and Kubernetes installation and configuration, we’ll need an EC2 instance with more vCPU and RAM. The minimum requirement for Docker and Kubernetes is 2 vCPUs and 2 GB RAM. For our initial setup, we’ll use the previously created AMI “centos7-base-image” and launch an instance using the “t3a.small” instance type. Although you can choose a different instance type with more resources, we’ll opt for “t3a.small” to keep costs minimal during the initial configuration.
Part 3
Installing and Configuring Docker Engine on CentOS 7
Step 1: Disable Swap
1. Log in to your instance as the “jenkins” user.
2.Disable swap using the following commands:
sudo su swapoff /dev/mapper/centos-swap
3. Verify that swap is disabled:
free -h
4. To make the change permanent, comment out the swap entry in
/etc/fstab
.5. Reboot the system:
reboot
Step 2: Install and Update Packages
1. Update the OS packages:
sudo yum -y update sudo yum -y upgrade
2. Install and enable the firewall:
sudo yum install -y firewalld sudo systemctl enable firewalld sudo systemctl start firewalld
3. Install additional packages:
sudo yum install epel-release -y sudo yum install -y unzip net-tools jq cloud-init
Step 3: Install AWS-CLI
1. Download and install AWS CLI:
sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" sudo unzip awscliv2.zip sudo ./aws/install
2. Verify the installation:
aws --version
Step 4: Install AWS Systems Manager Agent (SSM)
1. Install SSM Agent on CentOS 7:
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
2. Enable and start the SSM Agent service:
sudo systemctl enable amazon-ssm-agent sudo systemctl start amazon-ssm-agent
You’ve now set up the necessary CentOS 7 packages and utilities for your Kubernetes cluster.
Installing and Configuring Docker Engine
Step 5: Install Docker
Docker needs to be installed on both the master and worker nodes. We’ll start by installing it on the base image, which will be used for both types of nodes.
1. Install necessary utilities:
sudo yum install -y yum-utils
2. Add the Docker repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3. Install Docker packages:
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
4. Enable Docker service:
sudo systemctl enable docker
5. Add the “jenkins” user to the Docker group:
sudo usermod -aG docker jenkins
Step 6: Using “containerd” Instead of Docker (Kubernetes 1.24+)
Starting from Kubernetes version 1.24, Docker engine support has been removed. Instead, we’ll use “containerd,” which is already installed alongside Docker.
1. Download the
runc.<ARCH>
binary from here, verify its SHA256 checksum, and install it in/usr/local/sbin/runc
:sudo install -m 755 runc.amd64 /usr/local/sbin/runc
2. CNI plugins are already installed.
3. Update the
/etc/containerd/config.toml
file as follows:#disabled_plugins = ["cri"] #root = "/var/lib/containerd" #state = "/run/containerd" #subreaper = true #oom_score = 0 #[grpc] # address = "/run/containerd/containerd.sock" # uid = 0 # gid = 0 #[debug] # address = "/run/containerd/debug.sock" # uid = 0 # gid = 0 # level = "info" #[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] # ... [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] SystemdCgroup = true
4. Restart the containerd service:
sudo systemctl restart containerd
You’ve successfully completed the Docker installation on the base CentOS 7 operating system.
Part 4