Step 1: Install containerd
Containerd is downloaded and installed as the container runtime for Kubernetes. This package provides the required container management functionality.
wget https://github.com/containerd/containerd/releases/download/v1.6.16/containerd-1.6.16-linux-amd64.tar.gz -P /tmp/
tar Cxzvf /usr/local /tmp/containerd-1.6.16-linux-amd64.tar.gz
Step 2: Configure Systemd for containerd
The containerd systemd service is downloaded and enabled. This ensures that containerd starts automatically on boot.
Step 3: Install runc (containerd Runtime)
runc is installed as the container runtime for containerd. It is responsible for running the containers.
Step 4: Install CNI Plugins
This step downloads and installs the required CNI plugins, which are necessary for networking between containers in the Kubernetes cluster.
Step 5: Configure containerd
This command generates the default containerd configuration file at /etc/containerd/config.toml, which can be customized as needed.
Step 6: Edit etc/containerd/config.toml
manually edit and change
Step 7: Edit and Apply containerd Configuration
Install Kubernetes
Perfect now that containerd is installed, we can move to the fun part :)
Step 1: Become Root User
This command switches the current user to root, providing administrative privileges to run system-level commands. It is essential for performing installation and configuration tasks on the system.
Step 2: Update and Upgrade the System
These commands are used to update the package lists for the apt package manager (apt update) and then upgrade all installed packages to their latest versions (apt upgrade). This ensures that the system is up to date before installing new software.
Step 3: Change Terminal Hostname
This step changes the hostname of the system to master. The hostname identifies the machine on the network. It is important to set it properly to distinguish the Kubernetes master node. The hostnamectl command provides an easy way to manage the hostname.
Step 4: Add Hostname to the Hosts File
This step changes the hostname of the system to master. The hostname identifies the machine on the network. It is important to set it properly to distinguish the Kubernetes master node. The hostnamectl command provides an easy way to manage the hostname.
Step 5: Disable Swap
Disabling swap is essential for Kubernetes as it can interfere with pod scheduling and memory management. The swapoff -a command disables swap immediately, and free -m displays memory usage to verify the change.
Step 6: Disable Swap Permanently
In addition to disabling swap temporarily, this step involves editing the /etc/fstab file to prevent swap from being enabled after a reboot. The lsblk command helps to verify that no swap partition exists.
Step 7: Set Up IP Bridge for Node Network Communication
This step enables the necessary kernel modules for Kubernetes networking. The overlay module is required for pod networking, and br_netfilter is needed for network filtering in the bridge.
Step 8: Set Up Sysctl Parameters
This configures the system’s networking settings for Kubernetes. The parameters set up IP forwarding and enable network filtering for IPv4 and IPv6. The sysctl --system command applies the settings immediately.
Step 9: Install Required Packages
This command installs the required tools for managing HTTPS connections, including curl for downloading files and gpg for handling public keys.
Step 10: Retrieve Google Public Keyring for Kubernetes
This command retrieves and adds the Google Kubernetes public key to your system, allowing it to verify packages from Kubernetes repositories.
Step 11: Add Kubernetes APT Repository
This adds the Kubernetes package repository to your system’s APT configuration, enabling it to download Kubernetes components like kubelet, kubeadm, and kubectl.
Step 12: Update Package List and Install Kubernetes Components
The apt-get update command refreshes the package list with the newly added Kubernetes repository, and apt-get install installs the core Kubernetes tools: kubelet, kubeadm, and kubectl.
Step 13: Prevent Kubernetes Package Updates
This step ensures that the Kubernetes packages do not get updated automatically during system package upgrades.
Step 14: Initialize Kubernetes Cluster
Step 15: Install Flannel for Networking
Flannel is a popular network fabric for Kubernetes, providing an easy way to manage networking between pods across different nodes. Here’s how you can install and configure Flannel in your Kubernetes cluster:
Step 16: Apply Flannel Networking YAML
This command downloads and applies the Flannel network configuration to your Kubernetes cluster. The kube-flannel.yml file defines the necessary Kubernetes resources (like DaemonSets, ConfigMaps, etc.) to deploy Flannel as the network plugin. This will enable networking between pods and allow communication across the nodes in your Kubernetes cluster.
Success! Kubernetes is Up and Running
Congratulations! You have successfully installed and configured Kubernetes with containerd as the container runtime and Flannel as the network plugin. Your Kubernetes cluster is now set up and ready to manage containerized applications