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

# UPG Custom Resources

## UPGConfig

For now, it only contains NWI (Network Instance) configuration and PFCP
Heartbeats parameters, but later all of UPG-related settings will be there,
removing the need for CLI-based configuration of VPP instances.

`UPGConfig` CRs are targeted by means of
`fpp-manager.cennso.com/plumbing-instance` label, that needs to match
`FPP_INSTANCE_NAME` environment variable value passed to the
UPGManager pod.

```yaml
labels:
  fpp-manager.cennso.com/plumbing-instance: my-upg
```

Below is an example of UPGConfig CR with comments.

```yaml
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: UPGConfig
metadata:
  name: sample-upg-config
  namespace: upg-sample
  labels:
    # target particular UPGManager instance
    fpp-manager.cennso.com/plumbing-instance: vpp-my-upg
spec:
  # priority specifies the priority of this particular config when merging multiple
  # UPGConfig objects. The higher is priority value, the higher precedence this config
  # takes.
  priority: 100
  pfcp:                                # section defines parameters for PFCP Server (optional)
    heartbeat:                         # PFCP Heartbeat parameters (optional)
      retries: 10                      # Number of retries
      timeout: 5                       # Timeout between heartbeat requests in seconds
  nwis:
  - name: cp                           # when defining only NWI name
                                       # IPv4 and IPv6 table IDs will be set to 0
  - name: epc                          # name of the NWI
    ipv4TableID: 100                   # IPv4 table (VRF) ID
    ipv6TableID: 100                   # IPv6 table (VRF) ID
  - name: sgi
    ipv4TableID: 200                   # when only IPv4 is defined, IPv6 table is
                                       # configured for the same number that IPv4
    ipfixPolicy: FlowUsage             # IPFIX policy to use (optional)
    ipfixCollectorAddress: 10.20.30.40 # IPFIX collector address to use (optional)
    ipfixReportInterval: 7             # IPFIX report interval, 0 means the intermediate report is not sent, defaults to 0 (optional)
    observationDomainID: 42            # IPFIX ObservationDomainID field value (optional)
    observationDomainName: test        # IPFIX ObservationDomainName field value (optional)
    observationPointID: 4242           # IPFIX ObservationPointID field value (optional)
```

Note that IPFIX settings can be added regardless of whether
`ipfixPolicy` is set for the NWI. Both the policy and the settings
apply based on the egress NWI of the initial packet of the flow.

To activate IPFix per NWI, `ipfixPolicy` and `ipfixCollectorAddress`
should be configured. Then all the traffic will be reported in
IPFIX data packets.

For per flow IPFix activation, only `ipfixCollectorAddress` needs
to be defined in NWI configuration. Then IPFIX is enabled per session
using PFCP IE.

When multiple UPGConfig objects match this particular UPGManager
instance, they're merged together according to their `priority` value,
appending together the `nwis` section. The resulting config is called
"effective config".

There's special handling for the case when the same instance is also
targeted by `VPPConfig` instances some of them have `AfterCommands`
section. In this case, When effective `UPGConfig` changes for the
UPGManager instance, the UPGManager instance restarts.

## UPGApplication

The UPGApplication object creates an application for Application Detection Function.

Its parameters are:
- `rules` - a list of `L7Regexp` and `IPFilter` rules
- `proxy` - mandatory, boolean. Specifies whether to use the HTTP redirection function. Must be `true` if any `L7Regexp` is defined.

```yaml
apiVersion: upg-manager.cennso.com/v1alpha1
kind: UPGApplicationSet
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-instance: some-upg1-inst01
  name: upg-test-app
  namespace: default
spec:
  applications:
  - name: some-application-proxy
    proxy: true 
    rules: 
    - type: L7Regexp
      rule: 'https?://theserver.example.com'
    # - type: IPFilter
    #   rule: 'permit out ip from 198.19.1.1/32'

```
