Part 3


In Part 2, of this 5-part blog, we set up the CentOS-7 operating system. 

In this section, we will install the docker components on our base CentOS-7 . 

By the end of this article, we will create a new base image, which will have docker components installed and which can be used for any future docker-specific activity. 

We will now have to use a different type of EC2 instance for the docker and Kubernetes installation and configuration, as these require more vCPU and RAM. 

The minimum requirement for docker and Kubernetes is 2 vCPU & 2 GB RAM

We will use the previously created AMI “centos7-base-image” and launch an instance using “t3a.small“. You can use any other instance type with more vCPU or RAM, however, to keep costs to a minimum, we will use a “t3a.small” instance type for the initial configuration. 



STEP 1: Install and configure CentOS-7 packages and utilities. 



Important: After creating a new instance with the AMI we created in Part 2 and instance type “t3a.small“, log in as the “jenkins” user.

For the Kubernetes cluster to work, SWAP must be disabled at the operating system level. 


Disabling “swap”


We will disable the swap using the below steps. (Note: By default, swap is off in an EC2 instance)

    • $ whoami            # Should show user “jenkins”

    • $ sudo su                # Login as super user or root.

    • # blkid                     # To identify swap partition.

    • # lsblk                     # To search and identify swap partition.

    • # swapoff /dev/mapper/centos-swap          # To deactivate swap area.

    • # free -h                  # Should show swap area as 0 bytes.

    • # swapoff -a          # To remove from /proc/swaps.


Check the “/etc/fstab” file in the OS, incase there is an entry for the swap

In the /etc/fstab, comment the line : “/dev/mapper/centos-swap”            # This will permanently remove swap.


Reboot the system to ensure that all the necessary changes have taken affect. 

    • # reboot   


After rebooting the system, check 

    • $ free -h         # To test if swap is removed. 



Installing and upgrading all the operating system packages and utilities. 


Prior to installing the components, we MUST ensure that the OS is updated and upgraded with the latest centos-7 packages. 

Update all the necessary packages:

    • $ sudo yum -y update

    • $ sudo yum -y upgrade

    • $ sudo yum install -y firewalld

    • $ sudo systemctl enable firewalld

    • $ sudo systemctl start firewalld


In addition to the OS packages, there are additional packages & utilities we need to install for use when we setup the master or worker nodes. 


Installing additional packages on CENTOS7


    • $ sudo yum install epel-release -y

    • $ sudo yum update -y

    • $ sudo yum install -y unzip

    • $ sudo yum install -y net-tools        # Install network utility tools

    • $ sudo yum install jq -y                   # Install JSON Query 

    • $ sudo yum install -y cloud-init     # Install cloud initializing scripts



Instaling AWS-CLI


The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.


    • $ sudo curl -o “”

    • $ sudo unzip

    • $ sudo ./aws/install

    • $ aws –version

Installing AWS-SSM Agent


AWS Systems Manager Agent (SSM Agent) is Amazon software that runs on Amazon Elastic Compute Cloud (Amazon EC2) instances, edge devices, on-premises servers, and virtual machines (VMs). SSM Agent makes it possible for Systems Manager to update, manage, and configure these resources.

For installing AWS-SSM agent on CENTOS7 on Master & worker nodes.

    • $ sudo yum install -y

    • $ sudo systemctl enable amazon-ssm-agent

    • $ sudo systemctl start amazon-ssm-agent



This completes the installation of all the necessary packages and utilities required for the Kubernetes cluster. 



STEP 2: Install and configure Docker engine and components. 



Install docker on the VM. Docker has to be installed on Master and Worker nodes, hence we are installing on the base image, which will be used for both master and worker nodes. 

Run the below commands to install docker

    • $ sudo yum install docker-ce  docker-ce-cli docker-compose-plugin

    • $ sudo systemctl enable docker 

    • $ sudo usermod -aG docker jenkins

Docker installation process as mentioned in


IMPORTANT: In Kubernetes version 1.24 and above, support for docker engine is removed, so we have to use “contained”.

“contained” is already installed with docker in the previous step.

Download the runc.<ARCH>binary from, verify its sha256sum, and install it in /usr/local/sbin/runc

    • $ sudo install -m 755 runc.amd64 /usr/local/sbin/runc


CNI plugins are already installed.

    • Update the file /etc/containerd/config.toml as below:

#disabled_plugins = [“cri”]

#root = “/var/lib/containerd”

#state = “/run/containerd”

#subreaper = true

#oom_score = 0


#  address = “/run/containerd/containerd.sock”

#  uid = 0

#  gid = 0


#  address = “/run/containerd/debug.sock”

#  uid = 0

#  gid = 0

#  level = “info”


#  …


   SystemdCgroup = true

    • $ systemctl restart containerd ## restart the containerd




Part 2 –> Installing the Centos-7 system.


Part 4 –> Installation  & configuring the Kubernetes components.