This tutorial aims to guide you through the process of setting up a Kubernetes cluster, which includes creating a master node and several worker nodes.
By the end of this tutorial, you will be able to:
1. Understand the basic concepts of Kubernetes and how a cluster is structured.
2. Set up a master node and worker nodes on Kubernetes.
3. Demonstrate how to connect the nodes and manage the cluster.
Before starting this tutorial, you should have the following:
- Basic understanding of Docker and containerization.
- A system with Docker and Kubernetes installed.
In Kubernetes, a cluster consists of at least one cluster master and multiple worker machines called nodes. These master and node machines run the Kubernetes cluster orchestration system.
kubeadm init
command. This command initializes a Kubernetes control-plane node.sudo kubeadm init --pod-network-cidr=10.244.0.0/16
kubeadm join
command on the node machine, along with the token and the master IP address which was provided at the end of the kubeadm init
command on the master node.sudo kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash <hash>
Here is an example of initializing the Kubernetes master node.
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
The --pod-network-cidr
specifies the range of IP addresses for the pod network. If you decide to use a network plugin, ensure to use the same CIDR range.
Once you have the token and the hash, join the worker node to the cluster:
sudo kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash <hash>
Replace <token>
, <master-ip>
, <master-port>
, and <hash>
with your actual token, master IP address, master port, and hash.
In this tutorial, we covered the basics of Kubernetes clusters, how to set up a master node, and how to add worker nodes to the cluster. The next step is to learn about deploying apps on your cluster and managing them using kubectl.