SETTING UP A SINGLE-NODE KUBERNETES CLUSTER ON AWS

 

 

KUBERNETES FUNDAMENTALS

 

 

 

 

DEPLOYING A SINGLE-NODE KUBERNETES CLUSTER ON AWS

A COMPREHENSIVE GUIDE

 

 

 

Introduction

 

In the previous article (Part 3), we successfully installed Docker components on our AWS EC2 instance. Now, let’s configure the previously created AMI image with the necessary Kubernetes tools to set up our Kubernetes cluster.

By the end of this process, we’ll create a new base image that includes both Docker and Kubernetes components. This image can serve as the foundation for either the control plane (master node) or the data plane (worker nodes). We’ll install the following tools for setting up the Kubernetes cluster. 

1. Kubeadm: kubeadm simplifies the process of bootstrapping a minimum viable Kubernetes cluster. It focuses solely on cluster initialization, not machine provisioning.

2. Kubectl: The Kubernetes command-line tool, kubectl, allows you to interact with Kubernetes clusters. You can use it to deploy applications, manage resources, and view logs.

3. Kubelet: The kubelet acts as the primary “node agent” running on each node. It registers the node with the API server, using either the hostname, an override flag, or cloud provider-specific logic.

 

Stay tuned for the next steps in our Kubernetes setup journey! 

 

 

 

Part 4

Configuring Kubernetes Components on CentOS 7

 

 

 

 

Step 1: Configuring Kubernetes Repository on CentOS 7

 

To install Kubernetes components, we need to configure the Kubernetes repository. Follow these steps on both the Master Node and any Worker Nodes you plan to use in your container setup:

1. Log in as the root user:

sudo su

2. Create the Kubernetes repository configuration file:

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

This sets up the necessary repository for Kubernetes packages. If you have any further questions, feel free to ask!

 

 

 

Step 2: Installing Kubernetes Components on CentOS 7

 

In this step, we’ll install essential Kubernetes components on both the master and worker nodes. Follow these instructions carefully:

1. Install the necessary packages on each node:

sudo yum install -y kubelet-1.24.3 kubectl-1.24.3 kubeadm-1.24.3 kubernetes-cni-0.6.1

2. Enable and start the kubelet service:

sudo systemctl enable kubelet
sudo systemctl start kubelet

3. Update IPtables settings:

sudo su
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system

4. Disable SELinux or set it to “permissive”:

sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

5. Reboot the system:

sudo su
reboot now

 

This completes the Kubernetes component installation.

IMPORTANT: After rebooting, create an Amazon Machine Image (AMI) of the system. This AMI will serve as the base for all future master and worker nodes in your Kubernetes cluster.

For detailed instructions on creating an AMI, refer to Part 2 of this series. 

 

 

Step 3: Configuring Ports for Kubernetes on Master and Worker Nodes

 

In the previous steps, we performed configuration on a single VM. Now, let’s create two EC2 instances:

1. Master Node: This instance will serve as the control plane for our Kubernetes cluster.

2. Worker Node: This instance will be part of the data plane, running workloads.

Important Considerations:

 

  • When creating the EC2 instances, give each a unique name (e.g., “master-node” and “worker-node”) for easy differentiation.
  • We’ll use the same AMI created in Step 2 for both instances.
  • Choose EC2 instances of type “t3a.small” with 2 vCPUs and 2 GB RAM.

 

 

Configuring Ports on the Master Node:

 

1. Log in to the Master Node using SSH or Putty as the “jenkins” user.

2. Run the following commands to open specific ports:

sudo firewall-cmd --permanent --add-port=6443/tcp
sudo firewall-cmd --permanent --add-port=2379-2380/tcp
sudo firewall-cmd --permanent --add-port=10250/tcp
sudo firewall-cmd --permanent --add-port=10251/tcp
sudo firewall-cmd --permanent --add-port=10252/tcp
sudo firewall-cmd --permanent --add-port=10255/tcp
sudo firewall-cmd --permanent --add-port=8285/tcp
sudo firewall-cmd --permanent --add-port=8472/udp
sudo firewall-cmd --add-masquerade --permanent
sudo firewall-cmd --permanent --add-port=30000-32767/tcp
sudo firewall-cmd --reload

 

 

Configuring Ports on the Worker Node:

 

1. Log in to the Worker Node using SSH or Putty as the “jenkins” user.

2. Run the following commands to open specific ports:

sudo firewall-cmd --permanent --add-port=10250/tcp
sudo firewall-cmd --permanent --add-port=10251/tcp
sudo firewall-cmd --permanent --add-port=10255/tcp
sudo firewall-cmd --permanent --add-port=8472/udp
sudo firewall-cmd --permanent --add-port=30000-32767/tcp
sudo firewall-cmd --add-masquerade --permanent
sudo firewall-cmd --permanent --add-port=8285/tcp
sudo firewall-cmd --reload

 

 

 

This completes the installation and configuration of all the Kubernetes components on the Centos-7 Master and Worker systems. 

 

 

 

 

Part 5