Local lightweight kubernetes Setup

k3d is a lightweight wrapper to run k3s in docker. k3d makes it very easy to create single- and multi-node k3s clusters in docker, e.g. for local development on Kubernetes.

Pre-requisites:

Installation Setup:

  • Install the k3d in your local machine.

  • wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash

Quick Start:

  • Create /kube directory. To use this directory for persistent data mount.

    mkdir /kube
  • Create a cluster with a single server node and 2 agents and mount the pre created directory.

    k3d cluster create --agents 2 -v /kube:/kube@agent[0,1] -v /kube:/kube@server[0]
  • Use the new cluster with kubectl, e.g.:

    kubectl get nodes