How to Install Kubernetes on Ubuntu

Follow these steps to install Kubernetes on your Ubuntu system.

Step 1: Update the System

sudo apt-get update
    sudo apt-get upgrade
    

Step 2: Install Docker

Install Docker, which is required for Kubernetes.

    sudo apt-get install -y docker.io
    

Step 3: Install Kubernetes Components

Install kubeadm, kubelet, and kubectl.

sudo apt-get install -y kubeadm kubelet kubectl
    

Step 4: Initialize Kubernetes Cluster

Initialize the Kubernetes cluster using kubeadm.

sudo kubeadm init
    

Step 5: Configure kubectl

Set up kubectl for the regular user.

mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    

Step 6: Install a Pod Network Add-on

Install a network add-on for the cluster.

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
    

Step 7: Join Worker Nodes

Join worker nodes to the cluster using the command provided by kubeadm init.

kubeadm join <your-master-node-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>
    

Step 8: Verify the Installation

Check the status of the nodes.

kubectl get nodes
    

Conclusion

You have successfully installed Kubernetes on your Ubuntu system. You can now start deploying applications on your Kubernetes cluster.

References

Additional Resources

For more information on Kubernetes, check out the following resources: