> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/fpp/2.9/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/2.9/crs.md).

# Custom Resources

>**NOTE:** For explanation of the Amberd concept used below, please refer to the [architecture document](https://docs.cennso.com/components/fpp/2.9/architecture.md).

FPP controls the lifecycle of FPP Amberd pods by synchronizing the set of `VPPDeployment` objects with the set of Amberd DaemonSets and StatefulSets. `VPPDeployment` objects define either a set of node-mode Amberds or a single instance-mode Amberds.

The VPP interfaces are configured through the `VPPInterface` CRs (custom resources). The FPP Operator applies the VPPInterface state to the Amberd 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 Amberd (a VPP-based workload). There are also `VPPConfig` objects which can be used to configure Amberds, both node-mode ("VPPSwitch") daemon pods and instance-mode pods derived from StatefulSets.

Both `VPPConfig` and `VPPInterface` objects, as well as `IPFIXExporter` objects, are targeted using labels. It's possible to target an Amberd where FPPManager receives the specific value of 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 in Amberds. This method is used by FPP-CNI for instance-mode Amberds:

```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 VPPSwitch node:

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

or all VPPSwitch nodes:

```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 `routingTableSelectors` field in the `VPPConfig` spec.

## VPPDeployment objects

`VPPDeployment` objects are used to manage the lifecycle of VPPs running on the cluster.

```yaml
---
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPDeployment
metadata:
  name: cgw1
  namespace: cgw-advanced
spec:
  # The 'instance' mode specifies a single VPP pod managed via a StatefulSet,
  # commonly used for CGWs (Connectivity Gateway).
  # The 'node' mode is used for VPPSwitch pods that are managed via DaemonSets
  type: instance

  # Setting 'disable: true' will cause all of the resources generated from this
  # VPPDeployment to be removed
  disable: false

  # vppOptions section contains "lower-level" VPP specific options
  vppOptions:
    # CNI binary directory for FPP-CNI plugin deployment.
    # Only used in the node mode, defaults to /opt/cni/bin
    # cniBinDir: /opt/cni/bin

    # enable CNI debug log in /tmp/cni.log
    # (not recommended for production!)
    # Only used in the node mode, defaults to false
    # cniDebug: true

    # Log level, one of debug, trace, info, error.
    # Defaults to debug
    logLevel: debug

    # multusNetworks specifies the names of Multus CNI NADs
    # (Network Attachment Definitions) to be used by the Amberd
    multusNetworks:
    - cgw1-ext
    - cgw1-int

    # Run VPP under GDB, providing more informative stack traces
    # in case of a crash. Defaults to false
    gdbEnabled: true

    # GDB commands to execute. Only used with gdbEnabled: true.
    # By default is empty
    gdbScript: "..."


    # Defines a name for MEMCAP collector used for distinguishing the traffic streams at MEMCAP Sink.
    # The default value is set to the Kubernetes worker node name or Statefulset instance name.
    # memcapName: someName

    # Defines the non-default path to MEMCAP Sink, used for traffic capturing.
    # The default value is /run/vppswitch/sink.sock
    # memcapSocketPath: /run/memcap/sink.sock

    # Defines a set of arbitrary labels attached to a MEMCAP stream.
    # memcapLabels:
    #   apn: test.cennso.com
    #   lane: lane-b

    # Specifies that VPP uses just one core.
    # Useful for testing purposes, defaults to false
    singleCore: true

    # disableDPDK disables the use of VPP DPDK driver.
    # Defaults to false
    disableDPDK: true

    # Stops VPP process in case it hangs. Defaults to false
    # Not yet implemented in FPP 2.0
    stopOnHang: true

    # Enables verbose tracing of VPP API calls.
    # Defaults to false. Not yet implemented in FPP 2.0
    traceAPICalls: true

    # Allows HyperThreading sibling cores to be used for VPP. For testing purposes only!
    # Defaults to false
    allowHtSiblings: true

    # Buffers to allocate per NUMA node. Defaults to 256000.
    # Smaller values can be used for test environments
    buffersPerNuma: 8192

    # NIC resources to allocate for the VPP pods for the use as
    # uplinks and external network interfaces (as configured in the VPPConfig)
    nicResources:
    - interfacePrefix: uplink0 # prefix of the DPDK interface names
      numRxQueues: 4 # number of RX queues
      numTxQueues: 4 # number of TX queues
      numRxDesc: 4 # number of RX descriptors
      numTxDesc: 4 # number of TX descriptors
      # resource name (corresponds to one provided by the SRIOV Network Operator SriovNetworkNodePolicy.spec.resourceName)
      resourceName: openshift.io/wl0_vfio
      count: 1 # number of resources to use

    # Use some physical NICs directly without SRIOV Network Operator
    directNICMappings:
    - interfacePrefix: nic # prefix of the DPDK interface name
      numRxQueues: 4 # number of RX queues
      numTxQueues: 4 # number of TX queues
      numRxDesc: 4 # number of RX descriptors
      numTxDesc: 4 # number of TX descriptors
      pciIDs:
      - "0000:8a:00.1"
      - "0000:8a:00e.3"

    # Static CPU cores to use instead of Kubernetes-allocated ones.
    # Not used by default. There should be no CPU limits for the Amberd
    # if this is specified.
    # staticCPUCores: "27,28,29,30,31"

    # Max number of CPU cores to be used, including the main core.
    # The remaining cores can be used by vhost kernel threads serving
    # TAP interfaces created by VPP. Defaults to 0, which disables the
    # mechanism, allocating all the cores available to the pod to VPP.
    maxCPUCores: 3

    # VPP heap size. Defaults to 6Gi. The VPPDeployment needs to have
    # enough resources specified to accommodate for the heap, buffers and
    # the statseg.
    heapSize: 300Mi

    # VPP stat segment size. Defaults to 512Mi.
    statSegSize: 512Mi

    # Enable coredump for the VPP process. Defaults to false
    enableCoredump: true

    # VPP buffer size in bytes
    # 3776 for memifs
    # 3648 for DPDK (real NICs)
    defaultDataSize: 3648

    # Use hugepages for VPP stats segment, buffers and heap.
    # Defaults to false
    useHugepages: false

    # Set VPP poll sleep, useful for local and CI deployments.
    # It reduces the CPU consumption.
    # pollSleepUs: 1000

  # podOptions specifies the options controlling the Amberd pod specs
  podOptions:
    # additional pod labels to apply to the Amberd pod
    podLabels:
      foo: bar

    # additional pod annotations to apply to the Amberd pod
    podAnnotations:
      foo: bar

    # imagePullSecrets to use for the pod
    imagePullSecrets:
    - name: mysecret

    # Termination grace period in seconds, defaults to 30
    terminationGracePeriodSeconds: 10

    # Use host PID namespace. Defaults to true for node pods, otherwise defaults to false.
    hostPID: true

    # Pod affinity specification
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 99
          podAffinityTerm:
            labelSelector:
              matchExpressions:
              - key: fpp-manager.cennso.com/plumbing-instance
                operator: In
                values:
                - cgw2
            topologyKey: "kubernetes.io/hostname"

    # Pod tolerations
    tolerations:
    - effect: NoSchedule
      key: example-key
      operator: Exists

    # additional init container specs to add to the Amberd pods
    additionalInitContainers:
    - name: init
      image: busybox
      command:
      - /bin/sh
      - -c
      - for i in `seq 10`; do echo hello world; done >/srv/hello.txt
      volumeMounts:
      - name: srv
        mountPath: /srv

    # additional containers to add to the Amberd pod
    additionalContainers:
    - name: init
      image: busybox
      command: ["/usr/local/bin/myscript.sh"]

    # the name of Service Account to use
    serviceAccountName: my-sa

    # node selector for the pod
    nodeSelector:
      kubernetes.io/hostname: fpp-cluster-control-plane

    # extra volumes to add to the Amberd pod
    additionalVolumes:
    - name: srv
      emptyDir: {}

  # VPP container options
  containerOptions:
    # Image to use
    image: registry.cennso.com/cennso-dev/fpp-manager:debug

    # Image pull policy
    imagePullPolicy: Always

    # Resource specifications
    resources:
      cpu: "2"
      hugepages-2Mi: 100Mi
      memory: 350Mi

    # Readiness probe options
    readinessProbeOptions:
      initialDelaySeconds: 3
      timeoutSeconds: 5
      periodSeconds: 3
      successThreshold: 2
      failureThreshold: 2

    # Liveness probe options
    livenessProbeOptions:
      initialDelaySeconds: 3
      timeoutSeconds: 5
      periodSeconds: 3
      successThreshold: 2
      failureThreshold: 2

    # Additional volume mounts for the VPP container
    additionalVolumeMounts:
    - name: srv
      mountPath: /srv

    # Command override for the VPP container.
    # Can be used for debugging purposes. It is recommended to
    # disable the probes if the default startup script is not used
    # command: ["/bin/bash", "-c", "sleep Infinity"]

    # Disables probes (for debugging purposes). Defaults to false
    disableProbes: true

  # daemonSet options are only used for node-mode Amberds
  daemonSetOptions:
    updateStrategy:
      type: OnDelete
    minReadySeconds: 3

  # objectSelectors can be used to customize the label matching
  # criteria for the RoutingTables
  objectSelectors:
    routingTableSelectors:
      matchLabels:
        foo: bar

  # References to VPPTool CRs that should be used as templates
  # for additional containers in the Amberd pod
  tools:
  - name: bird
  - name: bird-exporter
```

To disable VPPDeployment from CLI, run:

```bash
kubectl patch vppdeployment -n cgw-advanced cgw1 -p '{"spec":{"disable": true}}' --type=merge
```

To enable it back, run:

```bash
kubectl patch vppdeployment -n cgw-advanced cgw1 -p '{"spec":{"disable": false}}' --type=merge
```

## VPPTool objects

VPPTool objects describe templates for additional containers to be added to the Amberd pods.

>**CAUTION:** VPPTool is an **immutable** cluster-wide resource. If you want to provide any modification to custom resource objects, you must delete VPPTool and create it again. This restarts all Amberd pods that use this tool, which causes network downtime.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPTool
metadata:
  name: bird
spec:
  # image to use
  image: registry.cennso.com/cennso-dev/fpp-manager:debug

  # Image pull policy
  imagePullPolicy: Always

  # container resources
  resources:
    cpu: "2"
    hugepages-2Mi: 100Mi
    memory: 350Mi

  # volumes to add to the Amberd pod
  volumes:
  - name: srv
    emptyDir: {}

  # volume mounts for the tool container
  volumeMounts:
  - name: srv
    mountPath: /srv

  # liveness probe for the tool container
  livenessProbe:
    httpGet:
      path: /healthz
      port: probe

  # readiness probe for the tool container
  readinessProbe:
    httpGet:
      path: /readyz
      port: probe

  # extra environment variables
  env:
  - name: MY_VAR
    value: someval

  # command to execute within the image
  command: ["/usr/local/bin/bird-tool.sh"]

  # the list of config files to use
  configFiles:
  - name: bird.conf # the name of the file (without directory)
    # canRelod should be true if the config can be reloaded by
    # sending SIGHUP to the tool process
    canReload: true
```

## VPPConfig objects

VPPConfig objects can be used to configure VPP instances, be that VPPSwitch daemon pods (node-mode Amberds) or instance mode Amberds. `VPPConfig` lists VPP CLI commands that must be run by FPP Manager, which can use many interfaces that are configured using `VPPInterface` CRs.

When multiple VPPConfig objects match this particular FPPManager instance, they're merged together according to their `priority` value. The resulting config is called "effective config". When effective config changes for an active FPPManager instance, the FPPManager instance restarts. There's an exception from that rule, namely, `spec.routingTableSelectors` field. When the effective value of `spec.routingTableSelectors` changes (it being all of the `routingTableSelectors` lists specified in all of the applicable configs appended together, with duplicates removed), the FPP Manager instance is not restarted but rather just continues with the new `routingTableSelectors` being used.

>**CAUTION:** If VPPConfig targeting Amberd pods has `afterCommands` defined, Amberd pods are restarted after FPP Operator restart.

```yaml
---
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPConfig
metadata:
  name: vpp-webserver
  namespace: fpp-sample
  labels:
    # target particular instance-mode Amberd
    fpp-manager.cennso.com/plumbing-instance: vpp-webserver
spec:
  # priority specifies the priority of this particular config when merging multiple
  # VPPConfig objects. The higher is priority value, the higher precedence this config
  # takes.
  priority: 100

  # beforeCommands are executed immediately when the VPPConfig is loaded
  # by FPPManager, before configuring any interfaces
  beforeCommands:
  - create loopback interface instance 42

  # 'interfaces' section specifies the interfaces that must become
  # available and up before `afterCommands` section is run
  interfaces:
  # matches "name" from 'config:' in NetworkAttachmentDefinition,
  # which is propagated to ifName of the client (slave) memifs
  # See NetworkAttachmentDefinition examples further down in this document,
  # e.g. in the "memif" section
  - srv

  # 'routingTables' is equivalent to `vppctl ip table add`, which guarantees that
  # empty routing tables are created before the `afterCommands` section is run
  routingTables:
  - 10
  - 20

  # afterCommands are only run after all of the interfaces listed under 'interfaces:'
  # are ready
  afterCommands:
  - http static server www-root /srv uri tcp://{{ .Ifs.srv.IP }}/80 cache-size 2m fifo-size 60000 debug 2

  # routingTableSelectors specify the label selectors which are used
  # to select RoutingTable objects that apply to this VPP instance.
  # Separate selectors are ORed together, while labels/values within a single
  # selector are ANDed together.
  # If no routingTableSelectors are specified, the default targeting
  # mechanism is used for RoutingTable objects, too.
  routingTableSelectors:
  - label1: value1
    label2: value2
  - label3: value3

  # assumedInterfaces lists the interfaces that are assumed to exist
  # after all of beforeCommands from the effective VPPConfig are
  # executed, and are used for creation of Uplink and Extnet interfaces.
  # When any assumedInterfaces are specified, DPDK interfaces (that is,
  # interfaces specified via MAPPING_* / PCIDEVICE_* env vars) aren't
  # automatically used for uplinks or extnet unless they're explicitly
  # mentioned in assumedInterfaces.
  # assumedInterfaces: ["bond0.2001", "bond0.2002"]

  # externalNetworkConfig specifies the prefix name and settings for a physical
  # interface that can be configured as external network. This interface can
  # join the specified bridge domain (VXLAN id) or be used (after assigning IP)
  # as routing hop for internal networks defined in FPP.
  # The corresponding DPDK settings for the physical interface
  # will be added to startup.conf
  externalNetworkConfig:
    # ifacePrefix can be a prefix matching a physical DPDK interface (see `spec.assumedInterfaces`) or a VPPInterface object generated from uplink configurartion (e.g., `uplink-bond`).
  - ifacePrefix: ext-net
    # networkName refers to an FPPNetwork object from bridgeDomain value
    # is derived
    networkName: my-network
    # or bridgeDomain can be specified directly
    # bridgeDomain: 31
    # the list of IPv4 and/or IPv6 addresses to be propagated
    # to the VPPInterface objects corresponding to the external interfaces
    ips:
    - 10.0.0.1/24
    MTU: 1500
    # routing table to get table ID from for this interface
    tableName: my-routing-table
    # table (VRF) for the external network interface,
    # can be used in place of tableName
    # table: 300
    # bond mode, one of LACP / Broadcast / XOR / ActiveBackup / RoundRobin
    bondMode: ActiveBackup
    # bond lb algorithm, one of L2 / L34 / L23 / RR / BC (Broadcast) / AB (ActiveBackup)
    bondLbAlgo: L23
    # Create VLAN subinterface
    vlanId: 1001

    # disableBonding disables automatic bonding
    # disableBonding: true

    # memif field is used for testing, it creates a fake memif interface
    # in place of a real extnet interface
    # memif:
    #   id: 11001
    #   role: slave

    # count is used together with memif to create multiple fake
    # memif extnet interfaces. If id is specified for memif,
    # it is auto-incremented for each memif in the sequence
    # count: 3

  # config files for the VPPTools in the Amberd
  toolConfigs:
  - name: bird # the name of the VPPTool
    configFiles:
    - name: bird.conf # corresponds to the config file name in the VPP tool spec
      content: |
        router id 10.10.0.1;
        debug protocols all;
        protocol direct {
          interface "lo";
        }
        # ...

  # VPP configuration included in VPPConfig AfterCommands, that should not be overriden by
  # FPP Operator. For example, IPs are strictly managed by VPPInterface object.
  # manualConfig.ips can define IPs, which will not be removed by FPP Operator during reconcile loop.
  manualConfig:
    ips:
    - 10.10.0.2/24
```

This `Ifs` structure that can be used in the `afterCommands` has the following fields for each interface:

* `Name` contains the VPP interface name for the interface
* `IP` contains the IPv4 address for this interface, if any, or an empty string if there's no IPv4 address assigned for this interface
* `IPNet` contains CIDR (IPv4 / subnet) for this interface, if any, or an empty string if there's no IPv4 address assigned for this interface
* `IP6` contains the IPv6 address for this interface, if any, or an empty string if there's no IPv6 address assigned for this interface
* `IPNet6` contains CIDR (IPv6 / subnet) for this interface, if any, or an empty string if there's no IPv6 address assigned for this interface
* `Table` contains table (VRF) id for this interface (defaults to 0)

The IP address templating mechanism will not work correctly if there are multiple IPv4 addresses or multiple IPv6 addresses specified for the interface.

For VPPSwitch daemon pods, the config may also contain a `uplinkConfig` section that specifies the uplink configuration:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPConfig
metadata:
  name: fpp-config
  namespace: fpp
  labels:
    # matches all FPP nodes
    fpp-manager.cennso.com/plumbing-node: ""
spec:
  uplinkConfig:
    # bond mode, one of LACP / Broadcast / XOR / ActiveBackup / RoundRobin
    bondMode: LACP
    # bond lb algorithm, one of L2 / L34 / L23 / RR / BC (Broadcast) / AB (ActiveBackup)
    bondLbAlgo: L23
    # IP prefix len for IPv4 subnet
    prefixLen4: 24
    # IP prefix len for IPv6 subnet
    prefixLen6: 64
    # MTU for the uplink interface
    MTU: 9000
    # table (VRF) for the uplink interface. It's not recommended to change
    # this value.
    table: 5001
    # Create VLAN subinterface
    vlanId: 1000

    # memif field is used for testing, it creates a fake memif interface
    # in place of a real uplink interface
    # memif:
    #   id: 10001
    #   role: slave

    # count is used together with memif to create multiple fake
    # memif uplink interfaces. If id is specified for memif,
    # it is auto-incremented for each memif in the sequence
    # count: 3
```

The external network configuration code matches the name prefix specified in `VPPConfig` against physical interface names included in a `startup.conf` based on `MAPPING_` environment variables. Below is an example of a VPPConfig that matches all of the nodes and also enables bonding for the external network:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPConfig
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-node: ""
    name: fpp-config
  name: fpp-config
  namespace: fpp
spec:
  uplinkConfig:
    bondMode: ActiveBackup
    prefixLen4: 24
    prefixLen6: 64
  externalNetworkConfig:
  - ifacePrefix: ext-net
    bridgeDomain: 31
```

For this to work, we need to define the `MAPPING_` environment variables for the FPP Manager pod like this:

```
        - name: MAPPING_OPENSHIFT_IO_X540_EXTNET0
          value: ext-net0n
        - name: MAPPING_OPENSHIFT_IO_X540_EXTNET1
          value: ext-net1n
```

In the example above, 2 interfaces will be used for the ext-net external network defined in VPPConfig. The following VPPInterface objects will be created: `<node-name>-ext-net-0`, `<node-name>-ext-net-1`, and also a VPPInterface object for the bond named `<node-name>-ext-net-bond`.

VPPConfigs that contain external interfaces with IP assignment must match a single FPP node (via `fpp-manager.cennso.com/plumbing-node` label) or a single FPP instance (via `fpp-manager.cennso.com/plumbing-instance` label) to avoid IP conflicts:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPConfig
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-node: wk-4001.dev-04.ccl-01.eu.cennso.net
    name: fpp-config-wk4001
  name: fpp-config-wk4001
  namespace: fpp
spec:
  externalNetworkConfig:
  - bridgeDomain: 20
    ifacePrefix: ext-net
    ips:
    - 10.100.0.123/24
```

VPPInterfaces that are generated for uplinks and `extnet` interfaces are continuously synced against the VPPConfigs applicable to the current node/instance. The generated VPPInterface objects have a couple of special labels:

 * `fpp-manager.cennso.com/plumbing-physiftype`: indicates `uplink` or `extnet`
 * `fpp-manager.cennso.com/plumbing-physifrole`: specifies `standalone` (for a non-bonded interface), `member-N` (for a bond member), `bond` (for a bond), or `vlan` (for a subinterface).

## VPPInterface objects

`VPPInterface` CRs can be created manually, by the FPP-CNI or by the VPPSwitch, the latter being used for VXLAN meshing.

The name of the VPP interface is generated by VPP itself by default, e.g. `memif1/100`.  If `spec.ifName` is set, that value is used instead of the name of the interface.  The special case is the `spec.ifName` beginning with a dash (`-`). In this case, `spec.ifName` is updated using its value as a suffix for the VPP device name, so that `-mydev` as `spec.ifName` becomes `memif1/100-mydev`, and this name is also used as the VPP interface name. This suffix mechanism is used by FPP-CNI on the VPPSwitch side to provide meaningful names for the network interfaces corresponding to pods. There are several types of VPPInterface resources supported.

## VPPInterface: uplink/bond

This corresponds to VFs or NICs that VPPSwitch owns, e.g. DPDK interfaces. DPDK interfaces are available upon startup in VPP, so no extra NIC details are specified there. The `ifName` must match the name of the interface that is created upon VPP startup. The name itseft is based on `MAPPING_...` environment variable value (see the [Installation](https://docs.cennso.com/components/fpp/2.9/installation/multinode-direct-nic.md) document for details).

> **CAUTION:** Uplinks are generated automatically by FPP Operator. Manual modification are overriden.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: node1
  namespace: fpp
  # target VPPSwitch on the node node1
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  # VPP interface name
  ifName: uplink0
  # IP address of the node
  ips:
  - 10.150.0.3/24
  mtu: 9000
  # VRF to use
  table: 500
status:
  # status report by VPPSwitch
  ready: true
  swIfIndex: 1
  vppName: uplink0 # same as ifName
```

It's also possible to bond the uplink interfaces. If, for example, there are several uplinks configured like this:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  # also node1-{1..3}
  name: node1-0
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  # also uplink{1..3}n0
  ifName: uplink0n0
  mtu: 9000
```

they can be bonded together in a single uplink like this:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: node1-bond
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  bond:
    lb: L34
    members:
    - node1-0
    - node1-1
    - node1-2
    - node1-3
    # can also use ActiveBackup, XOR, Broadcast, RoundRobin
    mode: LACP
  ifName: bond0
  ips:
  - 10.150.0.3/24
  mtu: 9000
  table: 500
```

## VPPInterface: loopback

The loopback interface is useful when a VPP instance must create a local interface. One of the possible use cases is to expose a network gateway on the FPP node. This incorporates a CGW use case on FPP daemonset. You must specify on which node to create the gateway. Regular properties of a VPP interface can be defined as well: VPP interface name (**ifName**), IPs, MTU, routing table to use, FPPNetwork, or bridge domain to connect to.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: net-a-gw
  # target FPP node name
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  # Type needs to be set to loopback
  type: loopback
  # VPP interface name
  ifName: net-a-gw
  # IP address of loopback interface
  ips:
  - 10.150.0.3/24
  mtu: 9000
  # Routing table to use
  table: 100
  # Name of the FPPNetwork, to which the loopback interface will be bridged into
  networkName: net-a
  # Bridge domain can be configured directly, without using networkName
  bridgeDomain: 10
  # Specify the MAC address
  hardwareAddress: "de:ad:00:ce:23:4"
```

If the MAC address is not specified, it is generated to be unique. The loopback interface is set as a Bridge Virtual Interface (BVI) to be able to respond to the ping.

## VPPInterface: external network

When VPPConfig has the externalNetworkConfig section specified, each physical interface that matches the interface name prefix will be configured as an external network by the FPP Manager start sequence. External interfaces are marked with VPPInterface.Spec attribute Type set to `extnet`. The name of the VPPInterface object is constructed using the node name, externalNetworkConfig.Name and a number: `<node-name>-<ext-net-name>-<id>`.

When the type is not set, the VPPInterface object is considered to be an uplink interface.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: node1-ext-net-0
  namespace: fpp
  # target VPPSwitch on the node node1
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  ifName: ext-net0n0
  type: extnet
  bridgeDomain: 31
  mtu: 9000
status:
  # status report by VPPSwitch
  ready: true
  swIfIndex: 1
  memberCount:  0
  vppName: ext-net0n0
```

It's also possible to create a bond interface consisting of external interfaces. Prefix name defined in the `externalNetworkConfig.name` needs to match multiple physical interfaces mappings in FPP Manager `MAPPING_...` environment variable value.

## VPPInterface: VXLAN endpoint

This corresponds to a VXLAN tunnel endpoint. The endpoints are created internally by the VPPSwitch instances based on `VPPInterface` objects corresponding to uplinks, and `VXLAN` objects, so, most of the time, you don't need to create any `vxlanTunnel` type objects by hand, and they're reserved for possible special cases.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: nv-node1-31
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  bridgeDomain: 31
  ifName: vxlan31
  mtu: 9000
  vxlanTunnel:
    # the peer
    destIP: 10.150.0.3
    # this corresponds to the VRF in the uplink VPPInterface
    encapVRFID: 500
    instance: 31
    sourceIP: 10.150.0.1
    # VNI id
    vni: 31
status:
  # status report by VPPSwitch
  ready: true
  swIfIndex: 2
  vppName: vxlan31
```

## VPPInterface: GRE tunnel

This corresponds to a GRE tunnel endpoint. FPP supports only L3 GRE tunnels at the moment. Another GRE tunnel endpoint is expected to be present at the `destIP`, not necessarily provided by FPP. The `sourceIP` must correspond to an address of an interface belonging to this VPP instance. The traffic destined for the GRE interface will be encapsulated and sent from `sourceIP` towards the `destIP` using GRE datagrams. Conversely, the traffic arriving at `sourceIP` from the `destIP` will be decapsulated. It's possible to use another table ID for the encapsulated traffic by specifying `encapVRFID` inside the `greTunnel` section of the spec. GRE tunnel may have a `key` configured like it's defined in ``RFC 2890``. If present, should match similar configuration parameters on another GRE tunnel endpoint.

> **NOTE**: You cannot set **spec.ifName** for the GRE interface to values like `gre0` or `gre1` because of possible collision with the internal VPP interface name.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: mygre31
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-instance: mycgw
spec:
  bridgeDomain: 31
  # ifName for GRE cannot match such regex: ^gre[0-9]+$, for example: gre0, gre11
  ifName: mygre31
  mtu: 9000
  greTunnel:
    # the peer
    destIP: 10.150.0.3
    # source IP
    sourceIP: 10.150.0.1
    # This corresponds to the VRF used for the encapsulated packets.
    # Defaults to 0
    encapVRFID: 500
    # The VPP tunnel instance ID. Can be omitted, in which case it
    # will be generated. Doesn't affect anything, most of the time,
    # if ifName is set.
    # The instance ID is used to generate VPP interface names,
    # but FPP renames the interface according to ifName.
    instance: 31
    # Key for the tunnel may be omitted, by default Key will not
    # be used for GRE tunnels matching. If present, should be
    # configured for both GRE peers. Allowed range: 0 to (2^32) - 1
    key: 12345
    # The options may be omitted, defaults are listed below.
    # They control how the corresponding bits are copied
    # from the payload to the tunnel header during encap
    # and vice-versa during decap
    options:
      # handling of the DF bit during encap (none, copy, set)
      dfMode: none
      # copy DSCP bits during encap if true
      copyDSCP: false
      # copy the ECN bit during encap if true
      encapCopyECN: false
      # copy the ECN bit during decap if true
      decapCopyECN: false
      # compute flow hash on the inner packet for more entropy
      # during encap if true
      encapInnerHash: false
      # copy the hop-limit/TTL during encap if true
      copyHopLimit: false
      # copy the Flow Label during encap if true
      copyFlowLabel: false
status:
  # status report by VPPSwitch
  ready: true
  swIfIndex: 2
  vppName: mygre31
```

## VPPInterface: memif

Memifs are used to attach Amberds or other tools that use memifs, such as [Cisco TRex](https://trex-tgn.cisco.com/) to VPPSwitch. A pair of memif `VPPInterface` objects is created by FPP-CNI for each such network attachment.

Note that many of the `fpp-manager.cennso.com/...` labels below are used internally by FPP CNI which has generated the VPPInterface objects below.

Master memif:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: vpp-webserver-0-memif-1-fc2p2
  namespace: fpp-sample
  labels:
    fpp-manager.cennso.com/plumbing-container-id: f2a66d02f81ae739dffb29f8b54eb57fbe2fb32c
    fpp-manager.cennso.com/plumbing-ifname: net1
    fpp-manager.cennso.com/plumbing-instance-uid: 296f1d55-bbcd-45af-872a-c3dcb906a437
    fpp-manager.cennso.com/plumbing-memif-role: master
    fpp-manager.cennso.com/plumbing-node: fpp-cluster-control-plane
    fpp-manager.cennso.com/plumbing-pod-name: vpp-webserver-0
    fpp-manager.cennso.com/plumbing-type: memif
    fpp-manager.cennso.com/plumbing-vni: "1"
spec:
  bridgeDomain: 1
  hardwareAddress: 02:fe:09:d3:05:40
  # The name is set to '-net1` by FPP-CNI and then
  # updated by FPP Manager to avoid name collisions
  ifName: "memif1/100-net1"
  memif:
    id: 100
    role: master
    ringSize: 8192
    bufferSize: 4096
    # Queue-to-core assignment on the VPPSwitch (master) side.
    # corresponds to txPlacement in the NetworkAttachmentDefinition
    txPlacement: ["2", "3"]
  mtu: 9000
status:
  memberCount: 0
  ready: true
  swIfIndex: 2
  vppName: memif1/100-net1
```

Slave (client) memif. `ifName` is set to the `name` of `NetworkAttachmentDefinition` below. It is used as the VPP interface name in the VPP app:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-container-id: f2a66d02f81ae739dffb29f8b54eb57fbe2fb32c
    fpp-manager.cennso.com/plumbing-ifname: net1
    fpp-manager.cennso.com/plumbing-instance-uid: 296f1d55-bbcd-45af-872a-c3dcb906a437
    fpp-manager.cennso.com/plumbing-memif-role: slave
    fpp-manager.cennso.com/plumbing-pod-name: vpp-webserver-0
    fpp-manager.cennso.com/plumbing-type: memif
    fpp-manager.cennso.com/plumbing-vni: "1"
  name: vpp-webserver-0-memif-client-1-bnvd2
  namespace: fpp-sample
spec:
  hardwareAddress: 02:67:03:2d:20:be
  ifName: srv
  ips:
  - 10.0.0.1/24
  memif:
    id: 100
    role: slave
    # number of queues is only specified for master
    numRxQueues: 2
    numTxQueues: 2
    ringSize: 8192
    bufferSize: 4096
    # Queue-to-core assignment on the client (slave) side.
    # corresponds to clientTxPlacement in the NetworkAttachmentDefinition
    txPlacement: ["0", "1"]
  mtu: 9000
status:
  memberCount: 0
  ready: true
  swIfIndex: 1
  vppName: srv
```

Sample NetworkAttachmentDefinition with the CNI config from which FPP-CNI has derived the above VPPInterface:

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: vpp-net
  namespace: fpp-sample
spec:
  config: |-
    {
      "cniVersion": "0.3.0",
      "ipam": {
        "addresses": [
          {
            "address": "10.0.0.1/24"
          }
        ],
        "type": "static"
      },
      "mtu": 9000,
      "name": "srv",
      "type": "fpp-cni",
      "vni": 1,
      "vppIfaceType": "memif",
      "numRxQueues": 2,
      "numTxQueues": 2,
      "memifRingSize": 8192,
      "memifBufferSize": 4096,
      "txPlacement": ["2", "3"],
      "clientTxPlacement": ["0", "1"]
    }
```

The following additional tunable settings are available for memifs in the CNI config:

* `numRxQueues` (goes into `spec.memif.numRxQueues` on the slave memif interfaces): number of rx queues, defaults to 1
* `numTxQueues` (goes into `spec.memif.numTxQueues` on the slave memif interfaces): number of tx queues, defaults to 1
* `memifRingSize` (goes into `spec.memif.ringSize`) - the number of entries of RX/TX rings, defaults to 4096
* `memifBufferSize` (goes into `spec.memif.bufferSize`) - size of the buffer allocated for each ring entry, defaults to 2048
* `txPlacement` controls the core-to-tx-queue assignment on the VPPSwitch side, each entry corresponding to a tx queue on that side, so the number of items in the list must be equal to `numRxQueues` which describes the number of RX queues on the client side and thus also the number of TX queues on the VPPSwitch side
* `clientTxPlacement` controls core-to-tx-queue assignment on the client side. The number of entries must be equal to the `numTxQueues`, each entry corresponding to a tx queue on the client side.

## VPPInterface: memif without CNI

A newer way to connect a memif-based workload to VPP L2 switch was developed to omit the use of CNI.
The user creates just the client (slave) interface, and FPP Operator creates a matching ephemeral master memif.
Ephemeral means that the VPPInterface CR is not actually stored in the Kubernetes API Server.

The VPPInterface has to have:

- `plumbing-instance` label
- `attachToNetwork` parameter which must be a valid FPPNetwork
- Role `slave`
- IP address/mask

To define TX Placement for a master side of memif interface, `serverTxPlacement` needs to be defined in slave memif VPPInterface object.

If the targeted instance of UPG is v2.x, an additional `fpp-manager.cennso.com/legacy-instance=true` label is required.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-instance: vpp-webserver
    # If target is UPG 2.x
    # fpp-manager.cennso.com/legacy-instance: true
    fpp-manager.cennso.com/slice: default
  name: vpp-webserver
  namespace: fpp-sample
spec:
  attachToNetwork: fpp-test-network
  ifName: srv
  ips:
  - 10.0.0.2/24
  memif:
    role: slave
    # Optional parameters:
    ringSize: 4096
    bufferSize: 2048
    numTxQueues: 4
    numRxQueues: 2
  table: 0
  # TX placement for slave memif interface:
  # - number of elements needs to be equal to numTxQueues
  # - each element is a (comma-separated) list of one or more cores
  txPlacement: ["0","1","0","1"]
  # TX placement for master memif interface:
  # - the number of elements must equal numRxQueues
  # - each element is a core number, it can be a list of cores
  # - usually, core 0 in the FPP node daemonset is the management core
  serverTxPlacement: ["1","2,3,4"]
  mtu: 1500
```

## VPPInterface: tap

VPPInterface of type tap is used to connect pods that use Linux networking to the VPPSwitch. Note that in the example below, the IP address information is not included as it's handled by the CNI plugin itself in this case.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-container-id: 92b86f0e629c10966389ee1acfd9fff6e445147c
    fpp-manager.cennso.com/plumbing-ifname: net1
    fpp-manager.cennso.com/plumbing-instance-uid: 4b879b86-3789-421e-a636-caafec73a6ba
    fpp-manager.cennso.com/plumbing-node: fpp-cluster-control-plane
    fpp-manager.cennso.com/plumbing-pod-name: linux-app-0
    fpp-manager.cennso.com/plumbing-type: tap
    fpp-manager.cennso.com/plumbing-vni: "1"
  name: linux-app-0-tap-1-b4v8g
  namespace: fpp-sample
spec:
  bridgeDomain: 1
  hardwareAddress: 02:fe:12:d9:3f:ff
  ifName: tap0-net1
  mtu: 9000
  tap:
    hostIfName: net1
    hostNS: /var/run/netns/cni-3ab3b5f8-de69-93d1-8dba-b1333ee01e32
    numRxQueues: 2
    rxRingSize: 8192
    txRingSize: 8192
status:
  memberCount: 0
  ready: true
  swIfIndex: 1
  vppName: tap0-net1
```

Below is the sample NetworkAttachmentDefinition with the CNI config from which FPP-CNI has derived the above VPPInterface.

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: linux-net
  namespace: fpp-sample
spec:
  config: |-
    {
      "cniVersion": "0.3.0",
      "ipam": {
        "addresses": [
          {
            "address": "10.0.0.2/24"
          }
        ],
        "type": "static"
      },
      "mtu": 9000,
      "name": "tst",
      "type": "fpp-cni",
      "vni": 1,
      "vppIfaceType": "tap",
      "numRxQueues": 2,
      "tapTxRingSize": 8192,
      "tapRxRingSize": 8192
    }
```

It is also possible to specify multiple IP addresses for an interface:

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: linux-net
  namespace: fpp-sample
spec:
  config: |-
    {
      "cniVersion": "0.3.0",
      "ipam": {
        "addresses": [
          {
            "address": "10.0.0.2/24"
          },
          {
            "address": "fd8a:a9f:3294:1::20/64"
          }
        ],
        "type": "static"
      },
      "mtu": 9000,
      "name": "tst",
      "type": "fpp-cni",
      "vni": 1,
      "vppIfaceType": "tap",
      "numRxQueues": 2,
      "tapTxRingSize": 8192,
      "tapRxRingSize": 8192
    }
```

The following additional tunable settings are available for taps in the CNI config:

* `numRxQueues` (goes into `spec.tap.numRxQueues`): number of rx queues, defaults to 1
* `tapRxRingSize` (goes into `spec.tap.txRingSize`) - the number of entries of TX ring, defaults to 4096
* `tapTxRingSize` (goes into `spec.tap.txRingSize`) - the number of entries of RX ring, defaults to 4096

## VPPInterface: VLAN

VPPInterface of the `VLAN` type is used to create a sub-interface that processes packets with the `802.1q` VLAN ID tag attached.
Creating this sub-interface requires another interface on the same VPP that serves as a parent.
Every VPPInterface of the `VLAN` type corresponds with one sub-interface.
Due to limitations in VPP, the **ifName** parameter always changes to `<parentIfName>.<VLAN ID>`.

See the example of the VPPInterface of the `VLAN` type:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  name: nv-node1-31
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-node: node1
spec:
  ifName: myTap.42
  vlan:
    ID: 42
    parentIfName: myTap # ifName of some other VPPInterface on the same vpp
status:
  # status report by VPPSwitch
  ready: true
  swIfIndex: 2
  vppName: myTap.42
```

## SPAN configuration

SPAN mapping can be configured on any VPPInterface by adding `spanSource` field to its spec.  SPAN mappings work by applying SPAN settings that tell VPPSwitch to copy all of the traffic targeted towards the interface mentioned in `spanSource` towards the interface for which that `spanSource` is set in its spec.

`spanSource` can be defined in one of three ways:

1. By specifying the name of a particular VPPInterface
1. By specifying a set of labels that match a single VPPInterface
1. By specifying the name and namespace of a CNI-less slave memif

You can use all the above methods manually on the VPPInterface definition or automatically through the FPP-CNI configuration in **NetworkAttachmentDefinition**.

### VPPInterface object name

Sample definition of a tap interface with a SPAN source from another interface specified using name:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-container-id: 92b86f0e629c10966389ee1acfd9fff6e445147c
    fpp-manager.cennso.com/plumbing-ifname: net1
    fpp-manager.cennso.com/plumbing-instance-uid: 4b879b86-3789-421e-a636-caafec73a6ba
    fpp-manager.cennso.com/plumbing-node: fpp-cluster-control-plane
    fpp-manager.cennso.com/plumbing-pod-name: linux-app-0
    fpp-manager.cennso.com/plumbing-type: tap
    fpp-manager.cennso.com/plumbing-vni: "1"
  name: linux-app-0-tap-1-b4v8g
  namespace: fpp-sample
spec:
  bridgeDomain: 1
  hardwareAddress: 02:fe:12:d9:3f:ff
  ifName: tst
  mtu: 9000
  tap:
    hostIfName: net1
    hostNS: /var/run/netns/cni-3ab3b5f8-de69-93d1-8dba-b1333ee01e32
  spanSource:
    name: linux-app-1-tap-0-a298f
```

### Matching label of source VPPInterface

Sample definition of a tap interface with the SPAN source specified using labels:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPInterface
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-container-id: 92b86f0e629c10966389ee1acfd9fff6e445147c
    fpp-manager.cennso.com/plumbing-ifname: net1
    fpp-manager.cennso.com/plumbing-instance-uid: 4b879b86-3789-421e-a636-caafec73a6ba
    fpp-manager.cennso.com/plumbing-node: fpp-cluster-control-plane
    fpp-manager.cennso.com/plumbing-pod-name: linux-app-0
    fpp-manager.cennso.com/plumbing-type: tap
    fpp-manager.cennso.com/plumbing-vni: "1"
  name: linux-app-0-tap-1-b4v8g
  namespace: fpp-sample
spec:
  bridgeDomain: 1
  hardwareAddress: 02:fe:12:d9:3f:ff
  ifName: tst
  mtu: 9000
  tap:
    hostIfName: net1
    hostNS: /var/run/netns/cni-3ab3b5f8-de69-93d1-8dba-b1333ee01e32
  spanSource:
    matchingLabels:
      fpp-manager.cennso.com/plumbing-pod-name: linux-app-1
      fpp-manager.cennso.com/plumbing-vni: "1"

```

Example FPP-CNI NAD with SPAN configuration:

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: linux-net
  namespace: fpp-sample
spec:
  config: |-
    {
      "cniVersion": "0.3.0",
      "ipam": {
        "addresses": [
          {
            "address": "10.0.0.2/24"
          }
        ],
        "type": "static"
      },
      "mtu": 9000,
      "name": "tst",
      "type": "fpp-cni",
      "vni": 1,
      "vppIfaceType": "tap",
      "spanSource": {
        "matchingLabels": {
          "fpp-manager.cennso.com/plumbing-pod-name": "linux-app-1",
          "fpp-manager.cennso.com/plumbing-vni": "1"
        }
      }
    }
```

### VPPInterfaceRef for CNI-less SPANs

When the CNI-less feature is used, the SPAN source interface is not visible as a Kubernetes API object.

In this case, you must define **vppInterfaceRef** in the **spanSource** section when defining a Network Attachment Definition:

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: span-upg-sxb
spec:
  config: |-
    {
      "cniVersion": "0.3.0",
      "ipam": {},
      "mtu": 9000,
      "name": "span-upg-sx",
      "type": "fpp-cni",
      "vni": 1,
      "vppIfaceType": "tap",
      "spanSource": {
        "vppInterfaceRef": {
          "name": "upg-sample-sxb",
          "namespace": "upg-test"
        }
      }
    }
```

The **vppInterfaceRef** section must include the **name** and the **namespace** of the slave memif VPPInterface CR.

## FPPNetwork Objects

FPPNetwork is **cluster-scope** (non-namespaced) object denote separate L2 networks that are handled by this VPP installation. Presently only a single FPPNetwork type is supported: `vxlan`. FPP automatically creates a full VXLAN mesh across the nodes based on FPPNetwork and VXLAN objects.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: FPPNetwork
metadata:
  name: fpp-test-network
spec:
  id: 42
  type: vxlan
```

FPPNetwork objects can be referred to via `networkName` field in a VPPInterface spec or a `NetworkAttachmentDefinition` instead of specifying `bridgeDomain` and `vni` values, respectively. In that case, the value is taken from the `id` field of the `FPPNetwork` specified in `networkName`.

## VXLAN Objects

VXLAN objects are handled by the VPPSwitch to automatically create the full mesh between the nodes for each VNI for which VXLAN object exists. VXLAN objects are to be eventually replaced with FPPNetwork.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VXLAN
metadata:
  name: vxlan30
  namespace: default
spec:
  vni: 30
```

## RoutingTable objects

`RoutingTable` makes it possible to specify routes to be installed in VPP. `RoutingTable` objects are targeted to a node or a VPP-based app instance in the same way as VPPConfigs. Each table has an `id` and `addressFamily`. `addressFamily` can be either `IPv4` or `IPv6`. Multiple routing tables with the same `id` are allowed; in this case, they're merged together.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: RoutingTable
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-instance: upg
    name: upg-access-routes
  name: upg-access-routes
  namespace: fpp-sample
spec:
  addressFamily: IPv4
  id: 100
  routes:
  # normal route with next hop and the target interface
  - cidr: 10.20.0.0/14
    nextHopAddress: 10.0.1.2
    nextHopInterface: access
  # blackhole route
  - cidr: 192.168.90.0/24
    nextHopAddress: blackhole
  # look up the next hop in another table
  - cidr: 192.168.90.0/24
    table: 123
```

The idea of reconciliation is mostly the same as with the VPPInterfaces:

1. Load RoutingTable objects and extract Route records from them
2. Load the current VPP FIB table state and convert it to the set of Route records
3. Create FIB tables based on RoutingTable IDs - if a routing table exists in VPP, skip creating.
4. The VPP tables that are not in RoutingTable objects are not deleted.
5. Delete routes that are in VPP but not in RoutingTables
6. Add routes that aren't in VPP but are in RoutingTables.

There are multipath routes, for which only some of the paths change, the whole route is re-created. This limitation can be fixed later, as VPP can add/remove individual paths, too.

## Firewall VPPACL objects

The **VPPACL** Custom Resource lets you configure a firewall in VPP using the Access Control List (ACL) rules. The object consists of two arrays: **rules** and **bindings**. Use **fpp-manager.cennso.com/plumbing-instance** to target the configuration towards an Amberd instance.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPACL
metadata:
  name: deny-traffic
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-instance: vpp-webserver
spec:
  # The **bindings** section contains a list of interfaces to which the following `rules` are applied.
  bindings:
      # ifname as specified in VPPInterface `spec.ifname`
    - ifName: srv
      # direction can be `input` or `output`
      direction: "input"
  # Rules are used to match traffic with a certain pattern and perform a defined action.
  rules:
      # Action to perform. The possible values are `deny`, `accept`, and `reflect`.
    - action: "deny"
      # Source CIDR
      source: "198.19.1.0/24"
      # Source port range
      srcPort: "1024-3000"
      # Destination CIRD
      dest: "198.19.2.0/24"
      # Destination port range
      dstPort: "80-8080"
      # Protocol. The possible values are `tcp`, `udp`, `sctp`, `icmp`, and `icmp6`.
      protocol: "tcp"
```

## VPPABF objects

The **VPPABF** Custom Resource lets you configure Access Control List (ACL)-based forwarding (ABF). The object consists of three arrays:
- **rules**
- **bindings**
- **forwarding**.

Use the `fpp-manager.cennso.com/plumbing-instance` label to target the configuration towards an FPP instance pod. See the configuration example of the VPPABF CR:

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPABF
metadata:
  name: custom-abf
  namespace: fpp
  labels:
    fpp-manager.cennso.com/plumbing-instance: cgw
spec:
  # The **bindings** section contains a list of interfaces to which the following `rules` are applied.
  bindings:
      # Interface name as specified in VPPInterface `spec.ifname`
    - ifName: srv
      # Specifies the order in which ABFs are applied when multiple ABFs are bound to the same interface.
      priority: 0
  # Forwarding lets you specify the route paths that the matched packets will follow.
  forwarding:
    - nextHopAddress: 192.168.1.1
      nextHopInterface: net
   # The table ID cannot be equal to `0`
    - lookupInTable: 100
  # Rules are used to match traffic with a certain pattern and perform a defined action.
  rules:
    - # Source Classless Inter-Domain Routing (CIDR)
      source: "198.19.1.0/24"
      # Source port range
      srcPort: "1024-3000"
      # Destination CIRD
      dest: "198.19.2.0/24"
      # Destination port range
      dstPort: "80-8080"
      # Protocol. The possible values are `tcp`, `udp`, `sctp`, `icmp`, and `icmp6`.
      protocol: "tcp"
```

For more information, read the [ACL-based forwarding](https://docs.cennso.com/components/fpp/2.9/abf.md) document.

## IPFIXExporter objects

`IPFIXExporter` objects are used to configure IPFIX Exporters in VPP.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: IPFIXExporter
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-instance: upg
  name: sample-exporter
  namespace: fpp-sample
spec:
  # Address of the IPFIX collector
  collectorAddress: 10.0.0.2
  # Port of the IPFIX collector
  collectorPort: 4739
  # Address of the IPFIX exporter (this VPP instance)
  srcAddress: 10.0.0.10
  # Routing table ID (defaults to 0)
  tableID: 14242
  # Path MTU between exporter and collector (68..1450)
  pathMTU: 1420
  # Number of seconds after which to resend template
  templateInterval: 60
  # Enable UDP checksum calculation
  udpChecksum: false
```

If a non-zero `tableID` is specified for an IPFIXExporter, the table with that ID must be present. For now, this is only guaranteed to  work for IPv4.

## FPP-CNI Setup diagrams

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

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