bcollard / kind-on-lima-public

source code for the blog post at https://baptistout.net/posts/kubernetes-clusters-on-macos-with-loadbalancer-without-docker-desktop/
27 stars 7 forks source link

= Run multiple KinD clusters on Lima

Demo: https://asciinema.org/a/gZysYfnX0XehRhTnKs8p0BTWS?speed=3&i=2

== Prerequisites

This guide now requires MacOS 13.0+ (Ventura).

Download and install the following tools:

=== Additional tools softwareupdate --install-rosetta xcode-select --install

== Getting started

=== Clone this repo First, clone the repo:

git clone git@github.com:bcollard/kind-on-lima-public.git
cd kind-on-lima

Take a look at the environment variables in .envrc and change the value of LIMA_WORKDIR to the path of the cloned repo on your machine.

Initialize the env vars for this directory:

direnv allow .

=== Using the scripts

Most of the scripts are available with Makefile targets.

List all the targets with

# Safely run `make` to list all the targets
make

=== MacBook preparation

Run the following make target to create a local data dir (LIMA_DATA_DIR env var) on your machine. A few docker images will be saved locally as archives. This may take a few minutes.

make prepare-mac-host
ls -l $LIMA_DATA_DIR

The data dir is mainly used by the docker registries to cache images.

=== Lima CLI Two methods here:

NOTE: -> In any case, double check that the env vars named LIMA_BIN and LIMACTL_BIN in .envrc are aligned with the method you chose!

=== Manage the Lima VM

The Lima machine that will be used by the following commands is the one defined in the LIMA_INSTANCE environment variable (see the .envrc file)

Example: LIMA_INSTANCE=vz will use the vz.yaml config file for Lima. And all the following commands will be executed on the VM named vz.

It's recommanded to use the vz instance (requires MacOS 13.0+) as it's the fastest one. It's based on macos Virtualization.framework. + People still using MacOS 12 or lower can use the docker instance which is using QEMU.

# list the Lima machines:
make list-machines
# create (and start) the VM:
make create
# stop the VM:
make stop
# start the VM:
make start
# delete the VM:
make delete

=== Configure the network E2E The following command will:

make config-network-end-to-end

Run this command everytime you restart the Lima VM.

=== Prepare the docker images

make prepare-docker-images

=== Spin up a new KinD cluster

#make kind-create <id> <name>
make kind-create 1 1-istio
make kind-create 2 2-gloo-edge
make kind-create 3 3-gloo-mesh-mgmt
make kind-create 4 4-gloo-mesh-cluster1
make kind-create 5 5-gloo-mesh-cluster2

The kind-create script takes care of:

=== Test connectivity E2E The following command will help you test the connectivity end-to-end.

It will deploy an nginx instance (pod) on the current cluster, expose the nginx service with a Service type LoadBalancer, and then curl the nginx service from the MacBook host.

make test
make clean-test

=== Manage KinD clusters

# list all the kind clusters:
make kind-list
# delete a specific kind cluster with:
make kind-delete 1-istio
# delete all kind clusters with:
make kind-delete-all

== History and WIP