> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/fpp/latest/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/latest/deployment-guides/multiple-vpp-operators.md).

# Multiple VPP Operators

## Multi VPP Operator per one cluster

You can run multiple VPP Operators in the same cluster, which allows them to be updated independently. Each operator is identified by one of the following labels:

- `fpp-manager.cennso.com/created-for` - name of the VPP Operator responsible for FPP instance deployment
- `fpp-manager.cennso.com/operated-by` - name of the VPP Operator responsible for creating the interconnection between the FPP node switch and
  the FPP instance, for example by providing the memif master part for the VPP interface

Example of this functionality would be one VPP Operator running FPP node type (VPP switch as daemonset) and other Operators deploying FPPs in instance mode.

### CRD and ServiceMonitor management

In environments where multiple VPP Operators target a single Core Cluster, the necessary FPP CRDs and ServiceMonitor resources are installed only once. The first VPP Operator deployed handles the installation, while subsequent operators automatically detect the existing resources and bypass this step.

### Deploy VPP Operators

Each VPP Operator is deployed via a `VPPOperator` CR and must be assigned a unique **spec.releaseName**. While multiple operators can target a single Core Cluster, they operate on mutually exclusive sets of FPP objects. The required CRDs and `ServiceMonitor` are provisioned by the operator with **spec.installCRDs** and **spec.installServiceMonitor** set to `true`. All other operators shall have these flags set to `false`.

```yaml
# Apply this on the Management Cluster
apiVersion: fpp.cennso.com/v1alpha1
kind: VPPOperator
metadata:
  name: node-operator
  namespace: cennso-infra
spec:
  version: <version>
  connectionSecretRef:
    name: cluster-name
    namespace: cennso-infra

  releaseName: node-op
  targetNamespace: fpp

  installCRDs: true
  installServiceMonitor: true
```

```yaml
# Apply this on the Management Cluster
apiVersion: fpp.cennso.com/v1alpha1
kind: VPPOperator
metadata:
  name: upg-operator
  namespace: cennso-infra
spec:
  version: <version>
  connectionSecretRef:
    name: cluster-name
    namespace: cennso-infra

  releaseName: upg-op
  targetNamespace: upg-ns

  installCRDs: false
  installServiceMonitor: false
```

### Reference operators from FPPDeployment

When creating an `FPPDeployment` with the `fpp-af-xdp` or `fpp-dpdk` compositions, use **spec.operatorRef** to reference the VPP Operator. The composition automatically resolves the operator's release name:

```yaml
apiVersion: fpp.cennso.com/v1alpha1
kind: FPPDeployment
metadata:
  name: example-fpp
  namespace: cennso-infra
spec:
  version: <version>
  connectionSecretRef:
    name: cluster-name
    namespace: cennso-infra
  operatorRef:
    name: node-operator
    namespace: cennso-infra
```

For `UPGDeployment`, configure the operator names directly:
  - Set **spec.operatorName** to the UPG operator name `upg-op`
  - Set **spec.nodeOperatorName** to the VPP Operator name `node-op`.

```yaml
apiVersion: fpp.cennso.com/v1alpha1
kind: UPGDeployment
metadata:
  name: upg
  namespace: cennso-infra
spec:
  connectionSecretRef:
    name: cluster-name
    namespace: cennso-infra
  compositionRef:
    name: upg-core-cluster-deployment
  version: 3.0.1
  repository: oci://registry.cennso.com/cennso/charts
  targetNamespace: upg-ns

  operatorName: upg-op
  nodeOperatorName: node-op
```

In this example, the `upg-op` VPP Operator is responsible for provisioning all FPP objects defined within the UPG chart. Conversely, the node-op VPP Operator manages the connectivity, attaching the UPG's VPP interfaces to the FPP node switch.

## Slice configuration

In some cases, you may want to have multiple VPP Operators controlling separate sets of FPP pods. You can do it using the slice mechanism, which looks at the designated label (`fpp-manager.cennso.com/slice`) that can be applied to FPP CRs or the namespaces in which they reside. The VPP Operator configured for a slice will only consider the resources belonging to their slice. All the objects that don't have the slice label are considered to have the `default` slice.

> [!CAUTION]
> **CAUTION:** VPP Operators with different slices will not create FPPNetwork meshing between workload places on nodes running a different FPP slice.

To deploy VPP Operator with a non-default slice, use the following VPPOperator configuration:

```yaml
apiVersion: fpp.cennso.com/v1alpha1
kind: VPPOperator
metadata:
  name: fpp-op
  namespace: cennso-infra
spec:
  connectionSecretRef:
    name: core-cluster-name
    namespace: cennso-infra

  slice: "testing"

  imagePullSecrets:
  - name: cennso-pull-secret

  releaseName: node-op
  logLevel: trace
```

VPP Operator with a non-default slice will reconcile only FPP objects labelled with `fpp-manager.cennso.com/slice: testing`.

To deploy the FPP node with slice `testing`, add label `fpp-manager.cennso.com/slice: testing` to the FPPDeployment configuration:

```yaml
apiVersion: fpp.cennso.com/v1alpha1
kind: FPPDeployment
metadata:
  namespace: cennso-infra
  name: fpp-node
spec:
  connectionSecretRef:
    name: core-cluster-name
    namespace: cennso-infra

  operatorName: node-op
  logLevel: trace
  labels:
    fpp-manager.cennso.com/slice: testing

  imagePullSecrets:
  - name: cennso-pull-secret
  ...
```

To deploy any Kubernetes workload (StatefulSet, Deployment or Daemonset) that requires the FPP interfaces, the pod should have an `fpp-manager.cennso.com/slice: testing` label. For example, you can do it in the StatefulSet manifest using `spec.template.metadata.labels`:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: linux-net-1
  namespace: fpp-test
spec:
  podManagementPolicy: Parallel
  replicas: 1
  selector:
    matchLabels:
      name: linux-app
  updateStrategy:
    type: RollingUpdate
  serviceName: linux-net-1
  template:
    metadata:
      annotations:
        k8s.v1.cni.cncf.io/networks: fpp-network-nic
      labels:
        fpp-manager.cennso.com/slice: testing
    spec:
      containers:
      - name: linux-app
        command:
        - /bin/sh
        - -x
        - -c
        - "ip r add 10.30.0.0/24 via 10.20.0.1 && ip a && while true; do sleep 1000; done"
        image: busybox
        imagePullPolicy: IfNotPresent
        securityContext:
          privileged: true
```
