Requirements
You need to have at least three nodes with 4 Gigabytes of RAM and 4 cores of CPU
This time I have one node for master and two nodes for worker nodes
Step 1: Install Kubernetes required packages
{
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo mkdir -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/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.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet=1.28.4-1.1 kubeadm=1.28.4-1.1 kubectl=1.28.4-1.1
sudo apt install containerd -y
}
Run these commands as well on the nodes
{
sudo apt install containerd -y
sudo modprobe br_netfilter
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
}
Initialize a master node
login to your master node and run the following command:
this command will go and download all the packages
sudo kubeadm init
The output of sudo kubeadm init
will be a command for joining worker nodes so run the above command in the worker nodes:
sudo kubeadm join xxx.xxx.xxx.xxx:6443 --token wqjxpm.vqupwqtp5xyvf1cg \
--discovery-token-ca-cert-hash sha256:637711aswr8e97dcd3fsfc8a1eda15725657d84dd39dfcbc8702050927ff4231
Make sure worker nodes are added
login to your master node and run the following command
kubectl --kubeconfig /etc/kubernetes/admin.conf get nodes
Output
NAME STATUS ROLES AGE VERSION
master NotReady control-plane 8m13s v1.28.4
worker-1 NotReady <none> 59s v1.28.4
worker-2 NotReady <none> 7s v1.28.4
Nodes are added but the STATUS is NotReady! isn’t weird?
It’s because you haven’t installed CNI (container network interface) so we can use Canal, Flannel, Calico, and Weave.
We’ll install Weave.
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml --kubeconfig path
After few seconds they will be Ready.
Testing
cat > nginx.yaml <<EOF
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
spec:
containers:
- name: nginx
image: nginx:alpine
EOF
# Check if it has been scheduled and became Ready
kubectl get pod nginx --namespace default --kubeconfig /etc/kubernetes/admin.conf
Great
Thanks