================================================================
Step 1 - Install Docker
================================================================
$ sudo apt-get install ca-certificates curl gnupg lsb-release
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
$ sudo systemctl enable docker
$ sudo systemctl status docker
If Docker is not running, start it with the following command:
$ sudo systemctl start docker
================================================================
Step 2 - Install kubeadm kubelet kubectl
================================================================
$ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
$ echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
$ sudo apt update
$ sudo apt install kubeadm kubelet kubectl
$ sudo apt-mark hold kubeadm kubelet kubectl
$ kubeadm version
================================================================
Step 3 - Prepare for Kubernetes Deployment
================================================================
# Disable all swap spaces with the swapoff command:
$ sudo swapoff -a
# Then use the sed command below to make the necessary adjustments to the /etc/fstab file:
$ sudo sed -i '/ swap / s/^\(.*\)$/#/g' /etc/fstab
# Load the required containerd modules. Start by opening the containerd configuration file in a text editor, such as nano:
$ sudo vi /etc/modules-load.d/containerd.conf
# Add the following two lines to the file:
overlay
br_netfilter
# Next, use the modprobe command to add the modules:
$ sudo modprobe overlay
$ sudo modprobe br_netfilter
# Open the kubernetes.conf file to configure Kubernetes networking:
$ sudo vi /etc/sysctl.d/kubernetes.conf
# Add the following lines to the file:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
# Reload the configuration by typing:
$ sudo sysctl --system
# Assign Unique Hostname for Each Server Node
$ sudo hostnamectl set-hostname master-node
================================================================
Step 4: Configure containerd
================================================================
# Open the kubelet file in a text editor.
NA
# Reload the configuration and restart the kubelet:
$ sudo systemctl daemon-reload && sudo systemctl restart kubelet
# Open the Docker daemon configuration file:
$ sudo vi /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
# Reload the configuration and restart Docker:
$ sudo systemctl daemon-reload && sudo systemctl restart docker
### containerd
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
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
sudo sysctl --system
sudo mkdir -p /etc/containerd
### containerd config
cat > /etc/containerd/config.toml <<EOF
disabled_plugins = []
imports = []
oom_score = 0
plugin_dir = ""
required_plugins = []
root = "/var/lib/containerd"
state = "/run/containerd"
version = 2
[plugins]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
base_runtime_spec = ""
container_annotations = []
pod_annotations = []
privileged_without_host_devices = false
runtime_engine = ""
runtime_root = ""
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
BinaryName = ""
CriuImagePath = ""
CriuPath = ""
CriuWorkPath = ""
IoGid = 0
IoUid = 0
NoNewKeyring = false
NoPivotRoot = false
Root = ""
ShimCgroup = ""
SystemdCgroup = true
EOF
### crictl uses containerd as default
{
cat <<EOF | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
EOF
}
### kubelet should use containerd
{
cat <<EOF | sudo tee /etc/default/kubelet
KUBELET_EXTRA_ARGS="--container-runtime-endpoint unix:///run/containerd/containerd.sock"
EOF
}
### start services
systemctl daemon-reload
systemctl enable containerd
systemctl restart containerd
systemctl enable kubelet && systemctl start kubelet
================================================================
Initialize Kubernetes on Master Node
================================================================
#Finally, initialize the cluster by typing:
$ sudo kubeadm init --control-plane-endpoint=master-node --upload-certs
Latest posts by Rajesh Kumar (see all)
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024