> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/fpp/3.2/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/fpp/3.2/crs.md).

# Custom Resources

All the FPP-related Custom Resources deployed on a Core Cluster must have the **fpp-manager.cennso.com/created-for** label with a value set to the name of the VPP Operator that should handle the object creation:

```yaml
labels:
  fpp-manager.cennso.com/created-for: node-op
```

VPP Operator controls the lifecycle of VPP pods by synchronizing the set of `VPPDeployment` objects with the set of Kubernetes DaemonSets and StatefulSets objects. `VPPDeployment` object define either a set of node-mode VPP pods or a single instance-mode VPP pod.

The VPP interfaces are configured through the `VPPInterface` CRs (Custom Resources). The VPP Operator applies the VPPInterface state to the VPP pod it targets and reports back the status in the **status** field of the resource. Each VPPInterface can be targeted at a node (the VPPSwitch on the node) or to a particular instance-mode VPP-based workload pod. There are also `VPPConfig` objects which can be used to configure VPP pod, both node-mode ("VPPSwitch") daemon pods and instance-mode pods derived from StatefulSets.

## Labeling

Objects like `VPPConfig`, `VPPInterface` and `IPFIXExporter` are targeted using labels.

One approach is to set to FPP objects **fpp-manager.cennso.com/plumbing-instance** label with a name of FPP instance name. The same FPP instance name is set inside the VPP pod using the `FPP_INSTANCE_NAME` environment variable:

```yaml
labels:
  fpp-manager.cennso.com/plumbing-instance: vpp-webserver
```

Another version of instance targeting uses `FPP_INSTANCE_UID` environment variable value, which usually contains pod UID value of VPP workload pod. This method is used by FPP-CNI for instance-mode FPP pods:

```yaml
labels:
  fpp-manager.cennso.com/plumbing-instance-uid: 296f1d55-bbcd-45af-872a-c3dcb906a437
```

**VPPInterface** is targeted via instance UID instead of instance name because otherwise, it wouldn't work with CNI. With CNI, the `netns` is created before the pod is started, and it may be torn down at an arbitrary moment later, even sometime after the pod is re-created. Targeting via instance name can run into a situation where VPPInterface CRs remaining for a while from dead UPG pods interfered with new UPG pods with the same instance name.

It's also possible to target specific FPP node pod:

```yaml
labels:
  fpp-manager.cennso.com/plumbing-node: node1
```

or FPP node pods:

```yaml
labels:
  fpp-manager.cennso.com/plumbing-node: ""
```

`RoutingTable` objects are also subject to this label-matching mechanism unless alternative selectors are specified using the **spec.objectSelectors.routingTableSelectors** field in the `VPPDeployment`.

## FPP-CNI Setup diagrams

CNI Setup diagram for tap interfaces:
![Sequence diagram](https://docs.cennso.com/api/assets/components/fpp/3.2/assets/tap.png)

CNI Setup diagram for memif interfaces:
![Sequence diagram](https://docs.cennso.com/api/assets/components/fpp/3.2/assets/memif.png)

## Bonding parameters

You can configure bonding for **spec.externalNetworkConfig** and **spec.uplinkConfig** in `VPPConfig`. Those settings are translated into `VPPInterface` object configuration.

There are several bond modes you can use to control how data is transmitted:

* `ActiveBackup` - Only one of the bonded interfaces is active. The active interface is changed on a link failure event.
* `Broadcast` - Broadcast every packet on all bonded interfaces.
* `LACP` - 802.3ad Dynamic link aggregation. The LACP protocol controls bonding.
* `RoundRobin` - Interfaces to transmit packets are selected sequentially.
* `XOR` - The interface to transmit packets is selected based on the packet hash.

The `LACP` and `XOR` modes respect the selection of the load-balancing algorithm. This algorithm selects how the packet's hash responsible for choosing the output interface is calculated. Values for `LACP` and `XOR` modes:

* `L2` - hash based on the MAC layer only
* `L23` - hash based on the MAC and IP layers
* `L34` - hash based on the IP and Transport layers

The order of active interfaces under a single-bonded interface changes on link failure and recover events.

### Active Backup bond mode

`ActiveBackup` bond mode follows these rules:

* Traffic is always transferred through a primary interface, which is the first active interface of the bonded ones.
* To prevent the delivery of duplicated frames, traffic is dropped on secondary interfaces.
    * This behaviour is specific to the `ActiveBackup` bond mode.

One of the consequences of those rules is that when two nodes are interconnected using bonded interfaces through other network devices, such as switches, and interfaces on the one side correspond with the interfaces on the other side in a way that traffic can take only one path between each pair of the corresponding interfaces, link failures are handled properly only if they can be detected on both corresponding interfaces. If a link failure is detected only on one side, a connectivity issue occurs. The reason is that the other side drops all the traffic that is received on a secondary interface.

Example of such setup:
![Sequence diagram](https://docs.cennso.com/api/assets/components/fpp/3.2/assets/active_backup_single_side_failure.svg)

In this setup, if `uplink0n0` is the primary interface on both nodes and the link between `sm-02` node and port `3` of the `sw-14` switch fails, a connectivity failure occurs even if traffic could be transferred through `uplink1n0` interfaces.

The `ActiveBackup` mode is vulnerable to the change of active interface order. For example, if the order of active bonded interfaces changes due to a link failure event with a following recover event, and traffic is delivered only to the same interface, which is now a secondary interface, all received traffic is dropped.
