Kubernetes Cluster Speedrun ???♂?

Kubernetes Cluster Speedrun ??♂?

Want to setup Kubernetes in less than 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        

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        

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        

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        

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        

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        

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        

  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        

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        

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        

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

https://[any-node-ip]:[NodePort]        

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]        

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.

要查看或添加评论,请登录

Mike Vincent的更多文章

  • Quark's Outlines: Python Lexical?Analysis

    Quark's Outlines: Python Lexical?Analysis

    Synopsis, Timeline, Problems & Solutions Synopsis of Python Lexical Analysis What is lexical analysis? If you want to…

  • Quark's Outlines: Python Code Blocks

    Quark's Outlines: Python Code Blocks

    Synopsis of Python Code Blocks What is a code block? A code block is a group of lines of code that go together. The…

  • Quark's Outlines: Python Classes

    Quark's Outlines: Python Classes

    Introduction to Python Classes Python classes are essential in modern programming, turning complicated code into…

  • The Python Underscore _

    The Python Underscore _

    Read this guide to learn how to use the underscore _ in Python. The underscore _ in Python serves as a powerful naming…

  • Ultimate Guide to Python's 19 Simple Statements (Definitions, History, Examples)

    Ultimate Guide to Python's 19 Simple Statements (Definitions, History, Examples)

    In Python, a statement is one complete instruction that tells the computer what to do. Python executes statements…

  • Python Loops: A Complete Guide

    Python Loops: A Complete Guide

    Learn how to use Python loops. All the loops.

  • How to Remember Big O Notation

    How to Remember Big O Notation

    Big O is everywhere, from coding to daily life. The key to remembering it? Know the patterns first, then practice…

  • Everything About Python Colons

    Everything About Python Colons

    The colon in Python is a small mark, but it plays a big role. It helps organize code, makes it easy to read, and tells…

  • Python Data Types & Data Structures

    Python Data Types & Data Structures

    Review this guide on Python data types and data structures, and print the illustrations to help with your study. You…

  • Everything We Know About NVIDIA Project DIGITS

    Everything We Know About NVIDIA Project DIGITS

    What’s so special about NVIDIA’s Project Digits? NVIDIA has unveiled Project DIGITS, a breakthrough home AI…

社区洞察

其他会员也浏览了