DEV Community

Cover image for Kubernetes Cluster Speedrun 🏃‍♂️
Mike Vincent
Mike Vincent

Posted on

Kubernetes Cluster Speedrun 🏃‍♂️

Want to setup Kubernetes in 60 seconds? Here's how.

Overview

This guide sets up a basic Kubernetes cluster in around 1 minute. Straight to the point, no unnecessary steps—just what’s needed to get it up and running quickly.

What is Kubernetes? 🤖

Kubernetes is like autopilot for your apps. When traffic surges, it scales up. Rolling out a feature? It does that without downtime. If a server crashes at 3 AM, Kubernetes takes care of it. It keeps your systems running and customers happy.

What you'll need 📋

To set up a Kubernetes cluster, you’ll need two Ubuntu machines—either virtual or physical, in a network that can talk to each other. This forms the cluster, and the process should take about 5 minutes. Make sure you have root or sudo access on both machines.

  • 1 Ubuntu VM for the control plane

  • 1 Ubuntu VM for the node

  • Root or sudo access on both machines

Single VM Setup Option 💻

If you only have one machine, that’s okay too. You can set up both the control plane and the worker node on the same machine by running the join command on the machine where the Kubernetes control plane is running.

Step 1: Install Kubernetes Components 🛠️

You’ll need Docker on every system—control plane, worker nodes, all of them. Kubernetes runs containers, and Docker’s the engine that makes it happen.

Next, install the core Kubernetes tools: kubelet, kubeadm, and kubectl.

  • kubelet: Manages container operations on each node.

  • kubeadm: Sets up the cluster, including the control plane.

  • kubectl: The command-line tool to manage and control the cluster.

After installing, lock the versions to keep everything stable and avoid unexpected updates.

On the machine you want as your control plane, and the machine you want as your node, run:

sudo apt-get update
sudo apt-get install -y docker.io apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | 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
Enter fullscreen mode Exit fullscreen mode

Step 2: Initialize Your Kubernetes Cluster 🚀

Now it's time to bring the control plane to life. This step sets up the heart of your cluster, which will coordinate everything the worker nodes do.

On the machine you want as your control plane, run:

sudo kubeadm init
Enter fullscreen mode Exit fullscreen mode

Step 3: Set Up kubectl 🎛️

Once the control plane is up, you need to configure kubectl. This tool lets you manage the entire cluster from the command line.

On the control plane, run:

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

Step 4: Install a Network Plugin 🌐

To get the cluster’s networking running, you’ll install Calico. This lets your nodes communicate within the cluster.

On the control plane, run:

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
Enter fullscreen mode Exit fullscreen mode

Step 5: Join Other Nodes 🤝

Now it's time to add worker nodes. You’ll need the join command to connect them to the cluster. You can join other VMs to the cluster, or even the same machine you initialized as the control plane can be added as a node.

On the control plane, run:

kubeadm token create --print-join-command
Enter fullscreen mode Exit fullscreen mode

This will output a join command that looks like this:

kubeadm join 192.168.1.100:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:1234...cdef
Enter fullscreen mode Exit fullscreen mode

Now, for each node you want to add to the cluster:

  1. If you haven't already, install the Kubernetes components on the machine you want to join as a node:
sudo apt-get update
sudo apt-get install -y docker.io apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | 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
Enter fullscreen mode Exit fullscreen mode
  1. On the worker node, use the join command generated from the control plane to connect it to the cluster:
sudo kubeadm join 192.168.1.100:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:1234...cdef
Enter fullscreen mode Exit fullscreen mode

This adds the node to your cluster.

Step 6: Verify Your Cluster ✅

With everything set up, check the status of your cluster. This ensures that all your nodes are connected and working together.

On the control plane, run:

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Step 7: Deploy a Test App 🧪

Now that your cluster is ready, try deploying a simple app to make sure everything is working as expected.

On the control plane, run:

kubectl create deployment hello-world --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-world --type=NodePort --port=8080
kubectl get services
Enter fullscreen mode Exit fullscreen mode

This creates and exposes a basic web app within your cluster. Access your app at:

http://[any-node-ip]:[NodePort]
Enter fullscreen mode Exit fullscreen mode

Congratulations! 🎉

You've successfully set up a Kubernetes cluster! This powerful tool will help you manage and scale your applications with ease. As you continue your Kubernetes journey, remember that there's always more to learn and optimize.

Mike’s Kubernetes Tome 👾

Here are all the commands you'll need, right in one place, to setup and test a Kubernetes cluster in less than 60 seconds.

# Step 1: Install Kubernetes Components 🛠️
# Run on Control Plane and Node
sudo apt-get update
sudo apt-get install -y docker.io apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | 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

# Step 2: Initialize Your Kubernetes Cluster 🚀
# Run on Control Plane
sudo kubeadm init

# Step 3: Set Up kubectl 🎛️
# Run on Control Plane
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# Step 5: Join Other Nodes 🤝
# Run on Control Plane, Read Output
kubeadm token create --print-join-command

# Step 6: Verify Your Cluster ✅
# Run on Control Plane
kubectl get nodes

# Step 7: Deploy a Test App 🧪
# Run on Control Plane
kubectl create deployment hello-world --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-world --type=NodePort --port=8080
kubectl get services
curl [any-node-ip]:[NodePort]
Enter fullscreen mode Exit fullscreen mode

Next Steps 🚶‍♂️

As an expert in AI, ML, automation, DevOps, and IT strategy, I can help optimize your Kubernetes deployment or shape your IT roadmap. Let's connect if you're a VP of IT or Engineering looking to upgrade your tech stack. Reach out to explore how I can add value to your team.


About Mike Vincent

Mike Vincent is an American software engineer and leading voice in AI and Machine Learning infrastructure. With a strong track record in building high-performing tech teams and driving strategic initiatives, Mike specializes in cloud computing, containers, and automation. Based in Los Angeles, he holds degrees in Linguistics and Management.

Connect with Mike:

🔗 linkedin.com/in/michael-thomas-vincent

Disclaimer: This material has been prepared for informational purposes only, and is not intended to provide, and should not be relied on for business, tax, legal, or accounting advice.

Top comments (0)