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:
-
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. Takelinux
+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.23.17 --config=- <<EOF kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 name: ambient nodes: - role: control-plane - role: worker - role: worker EOF
-
Install
istioctl
:curl -L https://istio.io/downloadIstio | sh - cd istio-1.22.2/bin chmod +x istioctl mv istioctl /usr/bin/
-
Install istio components using
istioctl
istioctl install
If you want to use
Kmesh
inworkload
mode, you should deployistio
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:
This will start a docker container namedmake docker
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:
You should specify thedocker build --build-arg arch=amd64 -f build/docker/kmesh.dockerfile -t $image_name .
image_name
.
- Build your code locally:
- Load the image to each cluster node
You should specify thekind load docker-image $image_name --name $cluster_name
image_name
andcluster_name
. - Edit the Kmesh daemonset:
Kmesh daemons are run as kubernetes
Daemonset
. You should modify the config of the daemonset, triggering a re-deployment.
This will open an editor, you can modify the image here. You can check whether the Kmesh daemons are all running by:kubectl edit ds kmesh -n kmesh-system
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:
Specially, for bpf logs:kubectl exec -it $kmesh_pod_name -n kmesh-system -- kmesh-daemon log --set default:debug
You can usekubectl exec -it $kmesh_pod_name -n kmesh-system -- kmesh-daemon log --set bpf:debug
uname -r
to check your kernel version. If it’s higher than5.13.0
, the bpf logs will be pushed to the user space. We can check them in the log file (withsubsys=ebpf
). Otherwise, you should usebpftool
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:
to cleanup these changes before you executemake clean
git add
command.
Reference
- Getting Started: https://istio.io/latest/docs/ambient/getting-started/
- Get Started with Istio Ambient Mesh: https://istio.io/latest/blog/2022/get-started-ambient/
- Install with Istioctl: https://istio.io/latest/docs/setup/install/istioctl/ Footer