Skip to main content

Deploy/Develop with Kind

Kind is a convenient tool for quickly deploying kubernetes cluster locally. We can use kind to create an istio cluster and deploy kmesh.

Deploy Kmesh in Kind

Let's start from setting up the required environment. You can follow the steps below:

Prerequisites

Before you begin, make sure you have the following installed and available on your PATH, and that you have the required permissions:

  • Docker (running): used to build images and run Kind nodes. You must be able to access the Docker daemon (e.g., your user is in the docker group or you run commands with sudo).
  • kind: the kind binary used to create local Kubernetes clusters. See the kind releases page for downloads.
  • kubectl: Kubernetes CLI to interact with the cluster. Follow the official install guide if needed.
  • istioctl: for installing Istio into the kind cluster (required for Kmesh dataplane features).
  • Adequate disk and memory: Kind clusters run as containers and need sufficient resources.

Install kind

Installing kind is very simple, because it's just a binary file. You can select the correct one according to the version and the architecture in the github releases page. Take linux + amd64 as example:

wget -O kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-linux-amd64
chmod +x kind
mv kind /usr/bin/

Create Kubernetes cluster using kind

You can take reference from the istio official document.

If you want to specified multiple workers or node image, you can:

kind create cluster --image=kindest/node:v1.30.0 --config=- <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: ambient
nodes:
- role: control-plane
- role: worker
- role: worker
EOF

Install istioctl

ISTIO_VERSION="1.24.0" # If you wish to use the Waypoint feature, the Istio version should be 1.23 ~ 1.25.

curl -L https://istio.io/downloadIstio | ISTIO_VERSION="${ISTIO_VERSION}" sh - && \
cd "istio-${ISTIO_VERSION}/bin" && \
chmod +x istioctl && \
mv istioctl /usr/bin/
note

If you want to use the Waypoint feature, the istio version should not be higher than 1.25

Install istio components using istioctl

istioctl install

If you want to use Kmesh in Dual Engine Mode, you should deploy istio in ambient mode, by adding an extra flag:

istioctl install --set profile=ambient

Install kubectl

Please follow the official guide: Install and Set Up kubectl on Linux.

Deploy Kmesh

Now, you are ready to deploy Kmesh in your local cluster. Feel free to follow the Kmesh Quick Start.

Develop Kmesh in Kind

You can follow the steps below to develop in kind:

Build your code and docker image locally

make docker

This will start a docker container named kmesh-build to build your code. Then, it will build the corresponding docker image.

You can also do this separately:

Build your code locally

make build

Build your docker image locally

docker build --build-arg arch=amd64 -f build/docker/dockerfile -t $image_name .

You should specify the image_name.

Notes on the build commands:

  • make docker: builds the code inside a reproducible container and produces a Docker image. Check the repo Makefile or build/ scripts for the image tag variable (e.g. IMAGE_NAME).
  • docker build -t $image_name: tag the image with a name you will later load into the Kind cluster (for example kmesh:local).

Load the image to each cluster node

kind load docker-image $image_name --name $cluster_name

You should specify the image_name and cluster_name.

Notes on loading images:

  • kind load docker-image <image> --name <cluster> copies a locally-built image into all Kind nodes so Pods can use it without pulling from a registry. Ensure <image> matches the tag used when building and <cluster> matches the Kind cluster name (default: kind).

Edit the Kmesh daemonset

Kmesh daemons are run as kubernetes Daemonset. You should modify the config of the daemonset, triggering a re-deployment.

kubectl edit ds kmesh -n kmesh-system

This will open an editor, you can modify the image here.

You can check whether the Kmesh daemons are all running by:

kubectl get po -n kmesh-system -w

Check logs

You can check the logs of a Kmesh daemon by:

kubectl logs $kmesh_pod_name -n kmesh-system

kmesh_pod_name is the name of a specified Kmesh pod.

You can change the logger level by:

kubectl exec -it $kmesh_pod_name -n kmesh-system -- kmesh-daemon log --set default:debug

Specially, for bpf logs:

kubectl exec -it $kmesh_pod_name -n kmesh-system -- kmesh-daemon log --set bpf:debug

You can use uname -r to check your kernel version. If it's higher than 5.13.0, the bpf logs will be pushed to the user space. We can check them in the log file (with subsys=ebpf). Otherwise, you should use bpftool to check them:

bpftool prog tracelog

Cleanup

The build process will modify some config-related files, if you want to push your code to github, please use:

make clean

to cleanup these changes before you execute git add command.

Reference