Video Thumbnail for Lesson
3.2: Local KinD Cluster

Local KinD Cluster

In this section, you will set up a Kubernetes cluster using KinD (Kubernetes in Docker), which is ideal for local development and testing environments.

Many local clusters can only run in a single node configuration, but KinD supports multi node clusters, which allows us to simulate having separate control plane and worker nodes.

1. Generate the config

Before creating the cluster, we'll generate a custom KinD configuration file (kind-config.yaml) tailored for our needs. This configuration includes defining local paths for persistent volume (PV) mounts.

# task kind:01-generate-config
#  - Generate KinD config with local absolute paths for PV mounts.
REPLACE_WITH_ABSOLUTE_PATH=${PWD} envsubst < kind-config.yaml.TEMPLATE > kind-config.yaml

2. Creating the Kubernetes Cluster

Next, we'll use the generated configuration to create a multi-node Kubernetes cluster using KinD.

# kind:02-create-cluster
#  - Create a Kubernetes cluster using KinD with custom configuration.
kind create cluster --config kind-config.yaml

3. Enabling Load Balancer Services

To enable load balancer services within KinD, we'll run the cloud-provider-kind plugin, which enhances cluster functionality.

# kind:03-run-cloud-provider-kind
#  - Run to enable load balancer services with KinD.
sudo cloud-provider-kind

At this point you should have a fully functioning local cluster to use for the rest of the hands on portions of the course.

If you run kubectl get nodes you should see a response something like this:

❯ kubectl get nodes
NAME                 STATUS   ROLES           AGE   VERSION
kind-control-plane   Ready    control-plane   18d   v1.30.0
kind-worker          Ready    <none>          18d   v1.30.0
kind-worker2         Ready    <none>          18d   v1.30.0

4. Deleting the Cluster

After completing your work with the cluster, you can clean up by deleting the cluster.

# kind:04-delete-cluster
#  - Delete an existing KinD Kubernetes cluster.
kind delete cluster