---
title: "Enable eBPF on an existing cluster"
description: "Switch a Calico Cloud connected cluster to the eBPF data plane on an existing installation as an alternative to the iptables data plane."
product: "Calico Cloud"
version: "v23.0.1"
section: "Operations"
canonical_url: "https://docs.tigera.io/calico-cloud/operations/ebpf/enabling-ebpf"
---

# Enable eBPF on an existing cluster

## Big picture

Enable the eBPF data plane on an existing cluster.

## Value

The eBPF data plane mode has several advantages over standard Linux networking pipeline mode:

- It scales to higher throughput.

- It uses less CPU per GBit.

- It has native support for Kubernetes services (without needing kube-proxy) that:

  - Reduces first packet latency for packets to services.
  - Preserves external client source IP addresses all the way to the pod.
  - Supports DSR (Direct Server Return) for more efficient service routing.
  - Uses less CPU than kube-proxy to keep the data plane in sync.

To learn more and see performance metrics from our test environment, see the blog, [Introducing the Calico eBPF data plane](https://www.projectcalico.org/introducing-the-calico-ebpf-dataplane/).

## Concepts

### eBPF

eBPF (or "extended Berkeley Packet Filter"), is a technology that allows safe mini programs to be attached to various low-level hooks in the Linux kernel. eBPF has a wide variety of uses, including networking, security, and tracing. You’ll see a lot of non-networking projects leveraging eBPF, but for Calico Cloud our focus is on networking, and in particular, pushing the networking capabilities of the latest Linux kernels to the limit.

## Before you begin

**Supported architecture and versions**

- x86-64

- arm64 (little-endian)

- Linux distribution/kernel:

  - Ubuntu 22.04 or above.
  - Red Hat v8.4 with Linux kernel v4.18.0-305 or above (Red Hat have backported the required features to that build).
  - Another supported distribution with Linux kernel v5.10 or above.
  - Immutable operating systems (e.g., Talos Linux): Ensure the `CgroupV2Path` in the `FelixConfiguration` CRD is set to a writable path.

#### Kernel version requirements for eBPF features

Some eBPF features require a higher kernel version than the base eBPF data plane.

| Feature                                                                                           | Minimum kernel version    | Details                                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Base eBPF data plane                                                                              | v5.10 (RHEL: v4.18.0-305) | CO-RE supported at this version for better performance                                                                                                                            |
| Log rules in eBPF mode                                                                            | v5.16                     | Logs sent to trace pipe via `bpftool prog tracelog`                                                                                                                               |
| [QoS bandwidth controls](https://docs.tigera.io/calico-cloud/networking/configuring/qos-controls.md) | v6.6                      | Requires `tcx` support. Established connection limits not supported with eBPF                                                                                                     |
| [DNS policy inline mode](https://docs.tigera.io/calico-cloud/network-policy/domain-based-policy.md)  | v5.17 (RHEL: v5.14)       | `BPFDNSPolicyMode: Inline` parses DNS responses in eBPF before they reach the application. Only wildcard prefixes (`*.x.y.z`) supported. Falls back to `NoDelay` on older kernels |

> **WARNING:** The minimum kernel version required for the eBPF data plane is v5.10, which includes support for [CO-RE (Compile Once - Run Everywhere)](https://docs.ebpf.io/concepts/core/). CO-RE significantly improves compatibility and performance across kernel versions. For access to all eBPF features, we recommend kernel v6.6 or above.

- An underlying network fabric that allows VXLAN traffic between hosts. In eBPF mode, VXLAN is used to forward Kubernetes NodePort traffic.

**Unsupported platforms**

- GKE
- MKE
- TKG

> **SECONDARY:** eBPF supports AKS with Calico CNI and Calico Cloud network policy. However, with AKS with Azure CNI and Calico Cloud network policy, kube-proxy cannot be disabled so the performance benefits of eBPF are lost. However, there are other reasons to use eBPF other than performance gains, as described in [eBPF use cases](https://docs.tigera.io/calico-cloud/operations/ebpf/use-cases-ebpf.md).

**Unsupported features**

- Clusters with some eBPF nodes and some standard data plane and/or Windows nodes
- IPv6
- Host endpoint `doNotTrack` policy (other policy types are supported)
- Floating IPs
- SCTP (either for policy or services)
- Tagged VLAN devices
- L7 logs
- Application layer policies
- Web application firewall (WAF)

**Recommendations for performance**

For best pod-to-pod performance, we recommend using an underlying network that doesn't require Calico Cloud to use an overlay. For example:

- A cluster within a single AWS subnet
- A cluster using a compatible cloud provider's CNI (such as the AWS VPC CNI plugin)
- An on-prem cluster with BGP peering configured

If you must use an overlay, we recommend that you use VXLAN, not IPIP. VXLAN has better performance than IPIP in eBPF mode due to various kernel optimizations.

## How to

- [Verify that your cluster is ready for eBPF mode](#verify-that-your-cluster-is-ready-for-ebpf-mode)
- [Configure Calico Cloud to talk directly to the API server](#configure-calico-cloud-to-talk-directly-to-the-api-server)
- [Configure kube-proxy](#configure-kube-proxy)
- [Enable eBPF mode](#enable-ebpf-mode)
- [Try out DSR mode](#try-out-direct-server-return-mode)
- [Reversing the process](#reversing-the-process)

### Verify that your cluster is ready for eBPF mode

This section explains how to make sure your cluster is suitable for eBPF mode.

To check that the kernel on a node is suitable, you can run

```bash
uname -rv
```

The output should look like this:

```text
5.10.0-26-generic #28~20.04.1-Ubuntu SMP Fri Jan 27 14:30:10 UTC 2023
```

In this case the kernel version is v5.10, which is suitable.

On Red Hat-derived distributions, you may see something like this:

```text
4.18.0-305.el8.x86_64 (mockbuild@x86-vm-08.build.eng.bos.redhat.com)
```

Since the Red Hat kernel is v4.18 with at least build number 305 (RHEL 8.4), this kernel is suitable.

### Configure Calico Cloud to talk directly to the API server

In eBPF mode, Calico Cloud implements Kubernetes service networking directly (rather than relying on `kube-proxy`). Of course, this makes it highly desirable to disable `kube-proxy` when running in eBPF mode to save resources and avoid confusion over which component is handling services.

To be able to disable `kube-proxy`, Calico Cloud needs to communicate to the API server *directly* rather than going through `kube-proxy`. To make *that* possible, we need to find a persistent, static way to reach the API server. The best way to do that varies by Kubernetes distribution:

- If you created a cluster manually (for example by using `kubeadm`) then the right address to use depends on whether you opted for a high-availability cluster with multiple API servers or a simple one-node API server.

  - If you opted to set up a high availability cluster then you should use the address of the load balancer that you used in front of your API servers. As noted in the Kubernetes documentation, a load balancer is required for a HA set-up but the precise type of load balancer is not specified.
  - If you opted for a single control plane node then you can use the address of the control plane node itself. However, it's important that you use a *stable* address for that node such as a dedicated DNS record, or a static IP address. If you use a dynamic IP address (such as an EC2 private IP) then the address may change when the node is restarted causing Calico Cloud to lose connectivity to the API server.

- `kops` typically sets up a load balancer of some sort in front of the API server. You should use the FQDN and port of the API load balancer, for example `api.internal.<clustername>` as the `KUBERNETES_SERVICE_HOST` below and 443 as the `KUBERNETES_SERVICE_PORT`.

- OpenShift requires various DNS records to be created for the cluster; one of these is exactly what we need: `api-int.<cluster_name>.<base_domain>` should point to the API server or to the load balancer in front of the API server. Use that (filling in the `<cluster_name>` and `<base_domain>` as appropriate for your cluster) for the `KUBERNETES_SERVICE_HOST` below. OpenShift uses 6443 for the `KUBERNETES_SERVICE_PORT`.

- For AKS and EKS clusters you should use the FQDN of the API server's load balancer. This can be found with

  ```text
  kubectl cluster-info
  ```

  which gives output like the following:

  ```text
  Kubernetes master is running at https://60F939227672BC3D5A1B3EC9744B2B21.gr7.us-west-2.eks.amazonaws.com
  ...
  ```

  In this example, you would use `60F939227672BC3D5A1B3EC9744B2B21.gr7.us-west-2.eks.amazonaws.com` for `KUBERNETES_SERVICE_HOST` and `443` for `KUBERNETES_SERVICE_PORT` when creating the config map.

Once you've found the correct address for your API server, create the following config map in the `tigera-operator` namespace using the host and port that you found above:

```yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: kubernetes-services-endpoint
  namespace: tigera-operator
data:
  KUBERNETES_SERVICE_HOST: '<API server host>'
  KUBERNETES_SERVICE_PORT: '<API server port>'
```

The operator will pick up the change to the config map automatically and do a rolling update of Calico Cloud to pass on the change. Confirm that pods restart and then reach the `Running` state with the following command:

```text
watch kubectl get pods -n calico-system
```

If you do not see the pods restart then it's possible that the `ConfigMap` wasn't picked up (sometimes Kubernetes is slow to propagate `ConfigMap`s (see Kubernetes [issue #30189](https://github.com/kubernetes/kubernetes/issues/30189))). You can try restarting the operator.

### Configure kube-proxy

In eBPF mode Calico Cloud replaces `kube-proxy` so it wastes resources (and reduces performance) to run both.\
This section explains how to disable `kube-proxy` in some common environments.

#### Clusters that run `kube-proxy` with a `DaemonSet` (such as `kubeadm`)

For a cluster that runs `kube-proxy` in a `DaemonSet` (such as a `kubeadm`-created cluster), you can disable `kube-proxy` reversibly by adding a node selector to `kube-proxy`'s `DaemonSet` that matches no nodes, for example:

```text
kubectl patch ds -n kube-system kube-proxy -p '{"spec":{"template":{"spec":{"nodeSelector":{"non-calico": "true"}}}}}'
```

Then, should you want to start `kube-proxy` again, you can simply remove the node selector.

> **SECONDARY:** This approach is not suitable for AKS with Azure CNI since that platform makes use of the Kubernetes add-on manager. the change will be reverted by the system. For AKS, you should follow [Avoiding conflicts with kube-proxy](#avoiding-conflicts-with-kube-proxy) below.

#### OpenShift

If you are running OpenShift, you can disable `kube-proxy` as follows:

```text
kubectl patch networks.operator.openshift.io cluster --type merge -p '{"spec":{"deployKubeProxy": false}}'
```

To re-enable it:

```text
kubectl patch networks.operator.openshift.io cluster --type merge -p '{"spec":{"deployKubeProxy": true}}'
```

### Avoiding conflicts with kube-proxy

If you cannot disable `kube-proxy` (for example, because it is managed by your Kubernetes distribution), then you *must* change Felix configuration parameter `BPFKubeProxyIptablesCleanupEnabled` to `false`. This can be done with `kubectl` as follows:

```text
kubectl patch felixconfiguration default --patch='{"spec": {"bpfKubeProxyIptablesCleanupEnabled": false}}'
```

If both `kube-proxy` and `BPFKubeProxyIptablesCleanupEnabled` is enabled then `kube-proxy` will write its iptables rules and Felix will try to clean them up resulting in iptables flapping between the two.

### Enable eBPF mode

To enable eBPF mode, change the `spec.calicoNetwork.linuxDataplane` parameter in the operator's `Installation` resource to `"BPF"`.

```bash
kubectl patch installation.operator.tigera.io default --type merge -p '{"spec":{"calicoNetwork":{"linuxDataplane":"BPF"}}}'
```

When enabling eBPF mode, preexisting connections continue to use the non-BPF datapath; such connections should not be disrupted, but they do not benefit from eBPF mode’s advantages.

> **SECONDARY:** The operator rolls out the change with a rolling update (non-disruptive) and then swiftly transitions all nodes to eBPF mode. However, it's inevitable that some nodes will enter eBPF mode before others. This can disrupt the flow of traffic through node ports.

### Try out direct server return mode

Direct server return (DSR) mode skips a hop through the network for traffic to services (such as node ports) from outside the cluster. This reduces latency and CPU overhead but it requires the underlying network to allow nodes to send traffic with each other's IPs.

In AWS, this requires all your nodes to be in the same subnet and for the source/dest check to be disabled. In GCP, the source/dest check should also be disabled, which can be done by enabling IP forwarding.

DSR mode is disabled by default; to enable it, set the `BPFExternalServiceMode` Felix configuration parameter to `"DSR"`. This can be done with `kubectl`:

```text
kubectl patch felixconfiguration default --patch='{"spec": {"bpfExternalServiceMode": "DSR"}}'
```

To switch back to tunneled mode, set the configuration parameter to `"Tunnel"`:

```text
kubectl patch felixconfiguration default --patch='{"spec": {"bpfExternalServiceMode": "Tunnel"}}'
```

Switching external traffic mode can disrupt in-progress connections.

### Reversing the process

To revert to standard Linux networking:

1. Reverse the changes to the operator's `Installation`:

   ```bash
   kubectl patch installation.operator.tigera.io default --type merge -p '{"spec":{"calicoNetwork":{"linuxDataplane":"Iptables"}}}'
   ```

2. If you disabled `kube-proxy`, re-enable it (for example, by removing the node selector added above).

   ```text
   kubectl patch ds -n kube-system kube-proxy --type merge -p '{"spec":{"template":{"spec":{"nodeSelector":{"non-calico": null}}}}}'
   ```

3. Since disabling eBPF mode is disruptive to existing connections, monitor existing workloads to make sure they re-establish any connections that were disrupted by the switch.
