Deploying Antrea on a Kind cluster

We support running Antrea inside of Kind clusters on both Linux and macOS hosts. On macOS, support for Kind requires the use of Docker Desktop, instead of the legacy Docker Toolbox.

To deploy a released version of Antrea on an existing Kind cluster, you can simply use the same command as for other types of clusters:

  1. kubectl apply -f https://github.com/antrea-io/antrea/releases/download/<TAG>/antrea.yml

Create a Kind cluster and deploy Antrea in a few seconds

Using the kind-setup.sh script

To create a simple two worker Node cluster and deploy a released version of Antrea, use:

  1. ./ci/kind/kind-setup.sh create <CLUSTER_NAME>
  2. kubectl apply -f https://github.com/antrea-io/antrea/releases/download/<TAG>/antrea.yml

Or, for the latest version of Antrea, use:

  1. ./ci/kind/kind-setup.sh create <CLUSTER_NAME>
  2. kubectl apply -f https://raw.githubusercontent.com/antrea-io/antrea/main/build/yamls/antrea.yml

The kind-setup.sh script may execute kubectl commands to set up the cluster, and requires that kubectl be present in your PATH.

To specify a different number of worker Nodes, use --num-workers <NUM>. To specify the IP family of the kind cluster, use --ip-family <ipv4|ipv6|dual>. To specify the Kubernetes version of the kind cluster, use --k8s-version <VERSION>. To specify the Service Cluster IP range, use --service-cidr <CIDR>.

If you want to pre-load the Antrea image in each Node (to avoid having each Node pull from the registry), you can use:

  1. tag=<TAG>
  2. cluster=<CLUSTER_NAME>
  3. docker pull antrea/antrea-controller-ubuntu:$tag
  4. docker pull antrea/antrea-agent-ubuntu:$tag
  5. ./ci/kind/kind-setup.sh \
  6. --images "antrea/antrea-controller-ubuntu:$tag antrea/antrea-agent-ubuntu:$tag" \
  7. create $cluster
  8. kubectl apply -f https://github.com/antrea-io/antrea/releases/download/$tag/antrea.yml

The kind-setup.sh is a convenience script typically used by developers for testing. For more information on how to create a Kind cluster manually and deploy Antrea, read the following sections.

As an Antrea developer

If you are an Antrea developer and you need to deploy Antrea with your local changes and locally built Antrea image, use:

  1. ./ci/kind/kind-setup.sh --antrea-cni create <CLUSTER_NAME>

kind-setup.sh allows developers to specify the number of worker Nodes, the docker bridge networks/subnets connected to the worker Nodes (to test Antrea in different encap modes), and a list of docker images to be pre-loaded in each Node. For more information on usage, run:

  1. ./ci/kind/kind-setup.sh help

As a developer, you do usually want to provide the --antrea-cni flag, so that the kind-setup.sh can generate the appropriate Antrea YAML manifest for you on the fly, and apply it to the created cluster directly.

Create a Kind cluster manually

The only requirement is to use a Kind configuration file which disables the Kubernetes default CNI (kubenet). For example, your configuration file may look like this:

  1. kind: Cluster
  2. apiVersion: kind.x-k8s.io/v1alpha4
  3. networking:
  4. disableDefaultCNI: true
  5. podSubnet: 10.10.0.0/16
  6. nodes:
  7. - role: control-plane
  8. - role: worker
  9. - role: worker

Once you have created your configuration file (let’s call it kind-config.yml), create your cluster with:

  1. kind create cluster --config kind-config.yml

Deploy Antrea to your Kind cluster

  1. kubectl apply -f https://github.com/antrea-io/antrea/releases/download/<TAG>/antrea.yml

Deploy a local build of Antrea to your Kind cluster (for developers)

These instructions assume that you have built the Antrea Docker image locally (e.g. by running make from the root of the repository).

  1. # load the Antrea Docker images in the Nodes
  2. kind load docker-image antrea/antrea-controller-ubuntu:latest antrea/antrea-agent-ubuntu:latest
  3. # deploy Antrea
  4. kubectl apply -f build/yamls/antrea.yml

Check that everything is working

After a few seconds you should be able to observe the following when running kubectl get -n kube-system pods -l app=antrea:

  1. NAME READY STATUS RESTARTS AGE
  2. antrea-agent-dgsfs 2/2 Running 0 8m56s
  3. antrea-agent-nzsmx 2/2 Running 0 8m56s
  4. antrea-agent-zsztq 2/2 Running 0 8m56s
  5. antrea-controller-775f4d79f8-6tksp 1/1 Running 0 8m56s

Run the Antrea e2e tests

To run the Antrea e2e test suite on your Kind cluster, please refer to this document.

FAQ

Antrea Agents are not starting on macOS, what could it be?

Some older versions of Docker Desktop did not include all the required Kernel modules to run the Antrea Agent, and in particular the openvswitch Kernel module. See this issue for more information. This issue does not exist with recent Docker Desktop versions (>= 2.5).

Antrea Agents are not starting on Windows, what could it be?

At this time, we do not officially support Antrea for Kind clusters running on Windows hosts. In recent Docker Desktop versions, the default way of running Linux containers on Windows is by using the Docker Desktop WSL 2 backend. However, the Linux Kernel used by default in WSL 2 does not include all the required Kernel modules to run the Antrea Agent, and in particular the openvswitch Kernel module. There are 2 different ways to work around this issue, which we will not detail in this document:

  • use the Hyper-V backend for Docker Desktop

  • build a custom Kernel for WSL, with the required Kernel configuration:

    1. CONFIG_NETFILTER_XT_MATCH_RECENT=y
    2. CONFIG_NETFILTER_XT_TARGET_CT=y
    3. CONFIG_OPENVSWITCH=y
    4. CONFIG_OPENVSWITCH_GRE=y
    5. CONFIG_OPENVSWITCH_VXLAN=y
    6. CONFIG_OPENVSWITCH_GENEVE=y