Friday, July 31, 2026

Create k8s master & worker node

 --https://share.google/aimode/mNvlnzfTE0U5g0GcL

To create a production-ready Kubernetes cluster using kubeadm, you must prepare one Master Node (Control Plane) with at least 2 vCPUs and 2 GB RAM, and one or more Worker Nodes with at least 1 vCPU and 1 GB RAM. [1, 2]
This guide uses Ubuntu and containerd as the container runtime interface (CRI). [1, 2, 3]

1. Prerequisites (Run on ALL Nodes)
Execute these commands on both the Master and Worker machines to configure the underlying system. [1]
  • Disable swap (Kubernetes requires swap to be off):
    bash
    sudo swapoff -a
    sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Enable IPv4 forwarding and load required kernel modules:
    bash
    cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
    overlay
    br_netfilter
    EOF
    
    sudo modprobe overlay
    sudo modprobe br_netfilter
    
    cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
    net.bridge.bridge-nf-call-iptables  = 1
    net.bridge.bridge-nf-call-ip6tables = 1
    net.ipv4.ip_forward                 = 1
    EOF
    
    sudo sysctl --system
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Install containerd:
    bash
    sudo apt-get update
    sudo apt-get install -y containerd
    sudo mkdir -p /etc/containerd
    containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
    sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
    sudo systemctl restart containerd
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Install kubelet, kubeadm, and kubectl:
    bash
    sudo apt-get update && sudo apt-get install -y apt-transport-https curl
    curl -fsSL https://k8s.io | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
    echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://k8s.io /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
    sudo apt-get update
    sudo apt-get install -y kubelet kubeadm kubectl
    sudo apt-mark hold kubelet kubeadm kubectl
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
    [1, 2, 3, 4, 5]

2. Initialize the Master Node (Run ONLY on Master Node)
The Master node coordinates the state of your cluster. [1, 2]
  • Initialize the cluster using a designated Pod network CIDR block:
    bash
    sudo kubeadm init --pod-network-cidr=192.168.0.0/16
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Configure cluster access for your non-root user (copied from the output of the command above):
    bash
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Deploy a Pod Network plugin (Calico) so your containers can communicate:
    bash
    kubectl create -f https://githubusercontent.com
    kubectl create -f https://githubusercontent.com
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • Copy the join token from the very end of your kubeadm init console output. It will look similar to this:
    bash
    kubeadm join <MASTER_IP>:6443 --token <TOKEN> --discovery-token-ca-cert-hash sha256:<HASH>
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
    [1, 2, 3, 4, 5]

3. Join the Worker Node (Run ONLY on Worker Node)
The worker node connects back to the master plane to begin receiving containers. [1]
  • Run your token command with root privileges:
    bash
    sudo kubeadm join <MASTER_IP>:6443 --token <TOKEN> --discovery-token-ca-cert-hash sha256:<HASH>
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
    [1, 2, 3, 4]

4. Verify Cluster Health (Run ONLY on Master Node)
Check if your cluster nodes are linked together successfully.
  • Check node status:
    bash
    kubectl get nodes
    
    குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
    [1]
Once all nodes change status to Ready, your Kubernetes cluster is fully constructed and capable of running application pods. [1, 2]
If you are setting this up, tell me:
  • What cloud platform or environment (AWS, bare-metal, VirtualBox) are you using?
  • Which Kubernetes version do you specifically want to run?
I can give you the exact firewall port configurations or helper scripts for your specific setup.