Skip to content

How to set calico IP_AUTODETECTION_METHOD

This document (000021401) is provided subject to the disclaimer at the end of this document.

Environment

  • A Rancher-provisioned or standalone RKE or RKE2 cluster
  • Kubernetes cluster nodes with multiple network interfaces
  • Calico is the Kubernetes cluster CNI plugin

Situation

When Calico has multiple interfaces, by default, it will choose the first-found interface for the vxlan traffic. To change, this behavior, the Calico auto detection method can be configured to point to a specific network interface. More information on the Calico auto detection methods can be found in the Calico documentation.

Resolution

The configuration differs based on the Kubernetes distribution. In the examples below the configured interface for Calico is ens192.

RKE

In RKE, you can specify the desired host network interface that Calico will use by creating the following configmap under the kube-system namespace.

apiVersion: v1
kind: ConfigMap
metadata:
  name: kubernetes-services-endpoint
  namespace: kube-system
data:
  IP_AUTODETECTION_METHOD: interface=ens192

RKE2

Rancher-provisioned RKE2 clusters

In a Rancher-provisioned RKE2 cluster you can specify the desired host network interface that Calico will use via the cluster add-on configuration:

  1. Navigate to Cluster Management
  2. Select the desired RKE2 Cluster
  3. Edit Config
  4. Add-On Config (under Cluster Configuration).

Here is an example Add-On config with the host network interface set to ens192

affinity: {}
apiServer:
  enabled: false
calicoctl:
  image: rancher/mirrored-calico-ctl
  tag: v3.28.1
[...]
installation:
  calicoNetwork:
    nodeAddressAutodetectionV4:
       interface: ens192

Standalone RKE2 clusters

In a standalone RKE2 cluster, you can specify the desired host network interface that Calico will use via a HelmChartConfig resource ( https://docs.rke2.io/helm#customizing-packaged-components-with-helmchartconfig)).

The HelmChartConfig below can used for this purpose by creating /var/lib/rancher/rke2/server/manifests/rke2-calico-config.yaml on one of the server nodes:

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: rke2-calico
  namespace: kube-system
spec:
  valuesContent: |-
    installation:
      calicoNetwork:
        nodeAddressAutodetectionV4:
          interface: ens192


Additional Information

Calico auto detection method documentation

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.