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. 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.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 in workload 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:

  1. 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:
    1. Build your code locally:
      make build
      
    2. Build your docker image locally:
      docker build --build-arg arch=amd64 -f build/docker/dockerfile -t $image_name .
      
      You should specify the image_name.
  2. 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.
  3. 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
    
  4. 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
    
  5. 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