
How to Create a Kubernetes Cluster in a Demo Environment with play-with-k8s
How to Create a Kubernetes Cluster in a Demo Environment with play-with-k8s 관련
As we've discussed earlier, a Kubernetes cluster is a set of machines (called nodes) that run containerized applications.
Setting up a Kubernetes cluster locally or in the cloud can be complex and expensive. To simplify the learning process, Docker provides a free, browser-based platform called Play with Kubernetes. This environment allows you to create and interact with a Kubernetes cluster without installing anything on your local machine. It's an excellent tool for beginners to get hands-on experience with Kubernetes.
🔐 Sign in to Play with Kubernetes
- Visit the platform at https://labs.play-with-k8s.com/.
- Authenticate:
- Click on the "Login" button.
- You can sign in using your Docker Hub or GitHub account.
- If you don't have an account, you can create one for free on Docker Hub or GitHub.

🚀 Create Your Kubernetes Cluster
Once signed in, follow these steps to set up your cluster:
Step 1: Start a New Session:
Click on the "Start" button to initiate a new session. This will create a new session giving you about 4 hours of play time, after which the cluster and it’s resources will be automatically terminated.

Step 2: Add Instances:
Then click on "+ Add New Instance" to create a new node (Virtual Machine).

This will open a terminal window where you can run commands.

Step 3: Initialize the Master Node:
In the terminal, run the following command to initialize the master node:
kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr <SPECIFIED_IP_ADDRESS>
You can find the command in the terminal. In my case, the IP address is 10.5.0.0/16
. Replace the <SPECIFIED_IP_ADDRESS>
placeholder with the IP address specified in your terminal.

This process will set up the control plane of your Kubernetes cluster.
Step 4: Add Worker Nodes:
If you want to add worker nodes, in the master node terminal, you'll find a kubeadm join...
command after running the kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr <SPECIFIED_IP_ADDRESS>
command.

Click on "+ Add New Instance" to create another node just as you did earlier.
Run this command in the new node's terminal to join it to the cluster:

Step 5: Configure the Cluster’s networking:
Navigate to the master node, and run the command below to configure the cluster’s networking.
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

Step 6: Verify the Cluster:
In the master node terminal (the first node with the highlighted user profile), run:
kubectl get nodes
You should see a list of nodes in your cluster, including the master and any worker nodes you've added.

Congratulations! You just created your very own Kubernetes cluster with 2 VMs: the master node (where the control plane resides), and the worker nodes (where the Kubernetes workloads, for example Pods, will be deployed).