by Technical Team at Avangels Tech

 

In this article, we will look at installing and configuring a single-node Kubernetes cluster on AWS. 

We have split this article into 5 parts.

Part 1 –> Introduction and Pre-requisites.

Part 2 –> Base OS (Ubuntu-18.04 LTS Bionic) installation.

Part 3 –> Installing and configuring docker components.

Part 4 –> Installing and configuring Kubernetes components.

Part 5 –> Creating and deploying the Kubernetes cluster.

 

Part 1

 

 

Kubernetes, also known as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications.

Containerized applications are applications that run in isolated runtime environments called containers. Containers encapsulate an application with all its dependencies, including system libraries, binaries, and configuration files.

What is a single-node Kubernetes cluster? A single-node cluster consists of a master node (called the control plane) and a worker node (called the data plane). 

Kubernetes deploys containers called pods in the Kubernetes world. Pods are the smallest unit provided by Kubernetes to manage containerized workloads. A pod typically includes several containers, which together form a functional unit or microservice.

Various cloud providers provide their own Kubernetes solutions, AWS’s EKS, Microsoft Azure’s AKS, Google’s GKE, etc. These are managed Kubernetes clusters and you pay the cloud provider a fixed fee for managing the control plane. The data-plane resources (virtual machines) are based on the application requirements. 

For our deployment, we will go with some assumptions and use some predefined OS and HW resources. 

The Kubernetes cluster will be deployed on AWS cloud.

We are assuming that you have a valid AWS account. (your account could be in a free tier period).

For this article, we have used AWS’s Asia Pacific (Mumbai) ap-south-1 region, but you can deploy this in any region you choose. 

We will use the default VPC and subnets that are created at the time when you created your account. 

Ensure that the subnet has access to the internet gateway (IG).

For this Kubernetes deployment, we will use Ubuntu 18.04 LTS – Bionic which supports 64-bit (x86) virtual machines as the OS for both the master and worker nodes.

We will create a new and dedicated user for administrating and monitoring the Kubernetes cluster. 

For the OS installation and initial activities, we will use the following instance family types:

OS installation –> t2.micro (1 vCPU + 1 GB RAM) –> 1 No.

Kubernetes cluster –> t3a.medium (2 vCPU + 4 GB RAM) –> 2 Nos.

EBS –> 10 GB –> io1

We will create a new EC2 user “jenkins”. This user will be the admin and will do all the installations. By default when you use a Ubuntu AMI, there is a default “ubuntu” user, but we will not use the default “ubuntu” user due to security reasons.

 

 

Below are the prerequisites before installing the OS.

 

 

Step 1: Configuring key-pair.

 

 

Create a new Key-pair for SSH login to the EC2 instance

Log in to your Amazon Web Services console.

Services –> EC2.

In the left tab –> Network & Security –> Key pairs

On the top –> Create key pair 

 

Enter the below values:

Name –> jenkins     

Key pair type –> RSA

Private key file format –> .pem

Tags –> 

Key = Name

Value = jenkins_ssh_key_pair

Create key pair

 

 

***IMPORTANT*** Download the key on your desktop/laptop as file “jenkins.pem” and we will use this later. You will not be able to download the key again to ensure that it is downloaded as “jenkins.pem” or “jenkins.ppk” based on the platform that you are using. 

 

System platform compatibility:

 

    Linux users — .pem file format

    Mac users — .pem file format

    Windows PowerShell users — .pem file format

    Windows PuTTY/Cygwin users — .ppk file format        

 

“THIS IS A ONE-TIME DOWNLOAD AND YOU CANNOT DOWNLOAD IT AGAIN !!!” 

 We are using mac OS, so we will be using the “jenkins.pem” file. The below steps need to be performed on the local computer for generating the public key.

$ chmod 700 “jenkins.pem”

$ ssh-keygen -y -f “jenkins.pem”

This generates a public key, which we will use when we create a new user in the OS for docker/kubernetes installation & configuration, so keep this key carefully. 

 

ssh-rsa

AAAAB3NzaC1yc2EAAAADAQABAAABAQCePm7WMuB4ZykXkQkn0fTMSfSlMFWFZ6j5hFhQgk72SgRScKf7twk0A/f5fsaYAZD1aQ+nREXVGyrozdYyu
W2qQDMr+GaUpPsJcr7NcJ/khthcJz1XUqI3VRuDTBNaNxBzXgITiXbkB8PF1JrXOiUY87lQjxqWOVFZ94W2hW+jimtXcZiIdQpNmE7VtE85BF9Tzi
/TmgFQ5Ax6fdCGCX4tlcnamlB7Nm10PhpTJeEkldZpD61vHkaoljucJ4DTm4lXOVVRVmbzpR7ReBVE/oPUM+qSdKcm9CIw0M5bWvou
aSvuBD9qYGRwlCF837W6KTZRmv/hqpjwCrbdDf+eUA0V

 

If you are using a Windows system, please refer to the below articles to generate the public key using the “*.ppk” file. 

Refer to the below article on how to use “.ppk” file using PuttyGen

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html

https://www.c-sharpcorner.com/article/difference-between-pem-and-ppk/#:~:text=PEM%20(Privacy%20Enhanced%20Mail)%20is,client%2C%20it%20does%20not%20support%20.

 

This completes SSH key creation.

 

 

Step 2: Configuring Security groups.

 

 

By default, when you create an AWS account a default security group is created. For this article, we will use this security group for SSH and for Kubernetes activities. 

Ensure that the SSH port is added to the default security group so that we can log in to the EC2 instance.  

On the EC2 page 

On the left tab –> Network & Security –> Security Groups

Click on the default security group –> Inbound rules (tab) –> Edit inbound rules (tab)

Add the below :

Type = SSH

Protocol = TCP (picks up by default)

Port = 22 (picks up by default)

Source = 0.0.0.0/0 (This means it can connect from any IP)

Description = Port for SSH (you can give any name/value)

Click –> Save rules (tab)

 

NOTE: For production systems, it is not advisable to use 0.0.0.0/0 as it can be a security risk. It is OK for development and testing environments. 

 

 

 

This completes the prerequisites for the Kubernetes installation. In the next article, we will configure the base OS which will be used for master and worker nodes.

 

Part 2 –> Installing the Ubuntu OS system.