> 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/installation/cgw-2.0.md).

# Deploy Fast Path Provider for CGW

This document describes the prerequisites and steps to deploy Fast Path Provider (FPP) for the purpose of the Connectivity Gateway (CGW) 2.0 use case.

## Prerequisites

- [Common prerequisites](https://docs.cennso.com/components/fpp/2.9/installation/installation-common.md)

## Steps

1. Install the [FPP chart](https://docs.cennso.com/components/fpp/2.9/installation/chart-configuration.generated.md) in the [`instance` mode](https://docs.cennso.com/components/fpp/2.9/installation/deployment-types.md) using the following chart configuration:

   The `instance` mode was introduced to enable VPP-based workloads. This makes it possible to manage workloads using FPP Custom Resources and configure VPP in a unified way. The benefit of using VPP-based applications is a possibility to employ fast vector packet processing with traffic not touching Linux kernel networking stack.

   One of possible application to use the VPP as a base is Connectivity Gateway (CGW), product of Travelping that currently uses Linux kernel to create external connectivity to outside of the cluster endpoints, with GRE tunnels and BGP routing. This application is called CGW-FPP in this section.

   >**CAUTION:** FPP-based CGWs should only be scheduled on the nodes with FPP version 2.0.0 or later serving as VPP Switch to have VPP interfaces configured properly.

   Below is a diagram with the CGW-FPP example deployment described further in this section:

   ![CGW-FPP Diagram](https://docs.cennso.com/api/assets/components/fpp/2.9/assets/cgw-fpp.svg)

   This is the full configuration of the CGW `values.yaml` file:

   ```yaml
   mode: instance
   cnfName: cgw

   imagePullSecrets:
   - name: image-secret

   externalNetworks:
     ext-net:  # this name is used as interface name prefix in startup.conf
       openshift.io/ext_vfio_gen3: sriov-network-operator/ext-gen3-sriov-vfio # this is SriovNetwork name

   vppConfigs:
   - spec:
     externalNetworkConfig:
     - ifacePrefix: ext-net
       ips:
       - 10.75.61.12/29
       mtu: 8930

   # Chart creates VPPInterface with proper GRE interface configuration
   vppInterfaces:
   - ifName: gre1 # name of the VPP Interface
     tableName: gre-inner-table
      ips:
      - 198.19.1.3/24
      greTunnel:
        sourceIf: ext-net0n0 # chart creates interface name by concatenation of <interface-name> and <0n0>
        destIP: 10.75.61.11
        # encapTableName: gre-outer-table
        # key: 1234 # optional support

   # Chart generates NAD with `int` interface for CGW-FPP
   networks:
     int: # int is a name of the interface
       type: memif
       vni: 1830 # VNI of FPPNetwork that traffic be routed into
       tableName: gre-inner-table
       ipv4:
         addresses:
         - 198.18.1.10/24

   routingTables:
     # gre-outer-table:
     #   id: 42
     #   addressFamily: IPv4
     #   routes:
     #   - cidr: 192.168.10.0/24
     #     nextHopAddress: 10.0.0.10
     gre-inner-table: # example of routing table that forwards traffic from remote GRE endpoint to internal FPP network
       id: 4242
       addressFamily: IPv4
       routes:
       - cidr: 198.19.65.0/24
         nextHopAddress: 198.19.1.4
         nextHopInterface: gre1
       - cidr: 198.18.65.0/24
         nextHopAddress: 198.18.1.2
         nextHopInterface: int

   # Minimal resource configuration that enables CGW to run:
   resources:
      cpu: "2"
      memory: 2Gi
      hugepages-2Mi: 2Gi

   heapSize: 1900M
   enableHugepagesAllocation: false

   # optional log level extension to more verbose mode:
   # vpp:
   #   traceAPICalls: true
   # logLevel: "trace"
   ```

2. Configure the `instance` mode based on the CGW example above.

   - Provide the CNF name:

   ```yaml
   mode: instance
   cnfName: cgw
   ```

   For FPP 2.0, the configuration above creates the VPPDeployment object with mode set to `instance`, which in turn creates Kubernetes `StatefulSet` object (as opposed to `DaemonSet` which is used for the `node` mode), and adds the `cennso.net/cnf: cgw` label to all resources created by the chart.

   - Define **imageSecret** to download the FPP Manager image from a private registry:

   ```yaml
   imagePullSecrets:
   - name: image-secret
   ```

   - Enable external connectivity. You can use an external network interface based on VF with `SriovNetwork` configuration which provides a VF for use by CGW-VPP. Also, you can assign the IP address of the external network using VPPConfig, for example:

   ```yaml
   externalNetworks:
     ext-net:  # this name is used as interface name prefix in startup.conf
       openshift.io/extnet: extnet0
       # openshift.io/extnet - this is the kubernetes resource name, based on SriovNetworkNodePolicy.spec.resourceName
       # extnet0 - this is SriovNetwork and Network Attachment Definition name, based on SrioVNetwork.metadata.name

   vppConfigs:
   - spec:
     externalNetworkConfig:
     - ifacePrefix: ext-net
       ips:
       - 10.75.0.12/29
       mtu: 9000
   ```

   `vppConfigs[].spec.externalNetworkConfig.ifacePrefix` must match `externalNetworks` key name (`ext-net`).

   - Configure the GRE interface, which can also be created using the chart:

   ```yaml
   vppInterfaces:
   - ifName: gre1
     tableName: inner-table
     ips:
     - 198.19.1.1/24
     greTunnel:
       sourceIf: ext-net0n0 # FPP creates interface name by concatenation of <interface-name> and <0n0>
       destIP: 10.75.0.11
       encapTableName: outer-table
       # key: 123 # optional to specify the GRE key
   ```

   The above configuration creates a tunnel from the external IP of the interface named `ext-net0n0` (`10.75.0.10/29`) to the destination IP somewhere in the external network, that is where the other endpoint of the GRE tunnel resides (`10.75.0.11/29`). The VPP interface for the local GRE tunnel endpoint is named `gre1` and is assigned the IP address `198.19.1.1`.

   It is possible to specify inner and outer routing tables for VPP GRE interfaces. These tables (`inner-table` and `outer-table`) can also be defined outside the FPP chart.

   Example of `inner-table` RoutingTable definition:

   ```yaml
   apiVersion: fpp-manager.cennso.com/v1alpha1
   kind: RoutingTable
   metadata:
     name: inner-table
   ...
   spec:
     addressFamily: IPv4
     id: 4242
     routes:
     - cidr: 198.19.65.0/24
       nextHopAddress: 198.19.1.4
       nextHopInterface: gre1
     - cidr: 198.18.65.0/24
       nextHopAddress: 198.18.1.2
       nextHopInterface: int
   ```

   - Create a memif interface
   A Network Attachment Definition can be used to provide routing between the GRE tunnel and the internal FPP network. Here we create a `memif` interface connected to the internal FPP network called `net-100`, the network must be created outside of a Helm chart:

   ```yaml
   networks:
     int:
       type: memif
       networkName: net-100
       tableName: inner-table
       ipv4:
         addresses:
         - 198.18.1.1/24
   ```

   In this example, CGW-FPP serves as a gateway to the FPP VXLAN network, connecting it to an external network through the GRE tunnel.

   The minimal resource configuration for evaluation purposes is as follows:

   ```yaml
   resources:
     cpu: "2"
     memory: 2Gi
     hugepages-2Mi: 1Gi

   heapSize: 1900M
   enableHugepagesAllocation: false
   ```
