This is part of a series on creating a Kubernetes cluster. In the previous post, we installed Kubernetes on the servers. In this post, we'll be creating the Kubernetes (k8s) cluster and configuring the master node.

To get started, we first need to create the cluster. There are two parts to creating the cluster.

  1. Initialize the cluster
  2. Create the pod network

Login to the master node and execute the following command to create the cluster using this server as the master node and an internal pod network of 10.244.0.0/16 (the default in the official docs).

sudo kubeadm init --pod-network-cidr=10.244.0.0/16.

After the command completes, you need to look at the end of the output and copy the kubeadm join command and save it for later use when joining the worker nodes to the cluster.

Copy the kubeadm join command

Also, if you want to be able to run k8s commands using this user, you need to run the commands in the output to configure the user with access to the cluster.

Run these commands to access k8s as your user

Before your cluster can become operational, it needs to have a pod network configured. This is what the cluster will use to communicate with the pods and manage the cluster's internal network.

The most common homelab pod network is called flannel. It can easily be added to your cluster by applying its configuration yaml file to the cluster. To apply flannel to your cluster, run this apply command. Note: If you changed the CIDR above, you will need to apply a modified copy of the file linked below with the correct CIDR.

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml

You can see the pods that are deploying by running kubectl get pods -n kube-system.

Once the pods are deployed, your master node should show as ready when you run kubectl get nodes.

Now that the cluster is created and the master is operational, it's time to join the worker nodes.