SETTING UP A SINGLE-NODE KUBERNETES CLUSTER ON AWS
KUBERNETES FUNDAMENTALS
DEPLOYING A SINGLE-NODE KUBERNETES CLUSTER ON AWS
A COMPREHENSIVE GUIDE
Introduction
In this article, we’ll configure the previously created Ubuntu base-OS image in Part 3 by installing essential Kubernetes components and tools for setting up the Kubernetes cluster. Specifically, we’ll install the following:
1. Kubeadm: kubeadm performs the necessary actions to bootstrap a minimum viable cluster. Its focus is on bootstrapping, not provisioning machines.
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 serves 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.
PART 4
Docker and Kubernetes Installation
Step 1: Setting Up System Kernel Modules
1. Disable swap memory:
$ sudo swapoff -a $ sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
2. Ensure necessary utilities and packages are installed:
$ sudo apt-get update && sudo apt-get install -y apt-transport-https curl
3. Log in as root for kernel module configuration.
4. Load required “containerd” modules:
# vi /etc/modules-load.d/containerd.conf
- Add the following lines:
overlay br_netfilter
5. Save and exit the file. Then run the following commands as root:
# modprobe overlay # modprobe br_netfilter
6. Configure system-level settings for proper Kubernetes network functionality:
# cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 net.bridge.bridge-nf-call-ip6tables = 1 EOF
7. Apply the configuration:
# sysctl –system
Step 2: Install and Configure “containerd”
1. Log in as the “jenkins” user.
2. Install “containerd”:
$ sudo apt-get update && sudo apt-get install -y containerd
3. Configure the “containerd” config file located at “/etc/containerd/config.toml”. Use a text editor (e.g., “vi”) to make the changes.
4. Comment out the following line in the “config.toml” file:
##disabled_plugins = ["cri"]
5. Add the following line to the “config.toml” file:
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] SystemdCgroup = true
6. Save the file and exit.
7. To apply the changes, restart “containerd”:
$ sudo systemctl restart containerd
Step 3: Installing and Configuring Kubernetes Components
1. Kubelet and Kubeadm Installation:
- Install “kubelet” and “kubeadm” on all nodes (Master and Worker). Optionally, we’ll also include “kubectl” in this base image to make it versatile for both roles.
- Set up the Kubernetes repository:
$ sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add – $ sudo cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF $ sudo apt-get update
- Install specific Kubernetes versions (e.g., ‘v1.24.3’):
$ sudo apt-get install -y kubelet=1.24.3-00 kubeadm=1.24.3-00 kubectl=1.24.3-00
- Prevent automatic upgrades:
$ sudo apt-mark hold kubelet kubeadm kubectl
2. Verification:
- Confirm successful installation:
$ kubeadm version $ kubectl version $ kubelet --version
3. AMI Creation:
- Create an Amazon Machine Image (AMI) from this VM. Give it a descriptive name (e.g., “ubuntu-docker-kubernetes-base-os”).
- Once the AMI and snapshot are created, terminate the AWS EC2 instance.
4. In the next step, we’ll configure the Master and Worker nodes using the created AMI for our Kubernetes cluster deployment.
Step 4: Configuring Specific Ports on Master and Worker Nodes
1. Master Node Configuration:
- Launch separate EC2 instances for the Master and Worker nodes.
- Use descriptive names for easy identification.
- Utilize the previously created AMI, which includes Docker and Kubernetes components.
- Choose an “t3a.small” EC2 instance type with 2 vCPUs and 2 GB RAM for both Master and Worker nodes.
- Log in to the Master node via SSH or Putty as the “jenkins” user.
- Open necessary ports for Kubernetes communication:
$ sudo ufw allow in ssh $ sudo ufw allow in 6443/tcp $ sudo ufw allow from 172.31.0.0/16 # Default VPC IPv4 CIDR $ sudo ufw default allow outgoing $ sudo ufw default deny incoming $ sudo ufw enable
2. Worker Node Configuration:
- Log in to the Worker node using SSH or Putty as the “jenkins” user.
- Open specific ports for Kubernetes operation:
$ sudo ufw allow in ssh $ sudo ufw allow from 172.31.0.0/16 $ sudo ufw allow in 30000:32767/tcp $ sudo ufw allow in 30000:32767/udp $ sudo ufw default allow outgoing $ sudo ufw default allow routed $ sudo ufw default deny incoming $ sudo ufw --force enable
This completes the installation and configuration of all Kubernetes components on the Ubuntu Master and Worker systems.
PART 5
Comments are closed.