Quick Kubernetes Cluster Setup in less than 10 Minutes

tl;dr

Introduction

This guide provides a fast method for setting up a local, miniature Kubernetes (k8s) cluster, primarily for testing or learning purposes. This is not an exhaustive tutorial on Kubernetes.

Previously, I utilized Minikube for quick Kubernetes testing, but have since shifted to Kind.

What is Kind?

kind is a tool for running local Kubernetes clusters using Docker container "nodes".

Reasons for preferring Kind over Minikube:

  1. Architecture: Kind operates differently from Minikube. While Kind creates Kubernetes clusters inside Docker containers, Minikube establishes a single-node Kubernetes cluster on a local machine.
  2. Deployment: Kind is designed for local development and testing, enabling rapid setup of multiple clusters. Minikube, in contrast, offers a more comprehensive Kubernetes experience for local development, including features like load balancing, secrets, and persistent volumes.

While kind does not require kubectl, having it installed is beneficial for following certain examples. For kubectl installation, refer to the official kubectl installation documentation.

Installation Requirements (using Homebrew):

Creating 4 Pods

Creating a Resource from a YAML File

kubectl apply -f deployment.yaml

where deployment.yaml contains:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: www
spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  replicas: 4
  minReadySeconds: 4
  selector:
    matchLabels:
      app: www
  template:
    metadata:
      labels:
        app: www
    spec:
      terminationGracePeriodSeconds: 2
      containers:
      - name: image1
        image: erkules/nginxhostname:v1

Verifying Pod Creation

Execute the following command to ensure the pods have been created successfully:

kubectl get pods

You should see output similar to:

NAME                   READY   STATUS    RESTARTS   AGE
www                    1/1     Running   0          10m
www-65b4c66678-kwk8x   1/1     Running   0          11m
www-65b4c66678-l6bzf   1/1     Running   0          11m
www-65b4c66678-nbb9s   1/1     Running   0          11m
www-65b4c66678-qg2qn   1/1     Running   0          11m

This quick setup guide should help you get a Kubernetes cluster up and running in no time, perfect for learning and experimentation.

Sources


logo-small-transparent 2.png

Dimitri Missoh | 2024-01-22