> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/upg/2.16/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.16/tutorials/multiple-access-networks.md).

# Deploy UPG with multiple Access Network Instances

This document describes how to deploy UPG with multiple Access Network Instances (NWIs) using a UPG Helm chart and additional configuration. In this tutorial, you will use the basic Packet Gateway (PGW) [Helm chart configuration](https://docs.cennso.com/api/assets/components/upg/2.16/assets/example-config/multi-grx-ip-values.yaml) and the required [Network Attachment Definitions (NADs) and additional UPGConfig custom resources (CRs)](https://docs.cennso.com/api/assets/components/upg/2.16/assets/example-config/multi-grx-ip-config.yaml).

## Define NWIs

First, define three Access Network NWIs:

- `epc` - NWI created by default by UPG chart
- `epc2` - second NWI created by additional UPGConfig CR
- `epc3` - third NWI also created by UPGConfig CR

Create `epc2` and `epc3` using the following UPGConfig CR:

```yaml
kind: UPGConfig
apiVersion: upg-manager.cennso.com/v1alpha1
metadata:
  name: pgw-u-nwis
  labels:
    fpp-manager.cennso.com/plumbing-instance: upg-inst01  # {HELM_DEPLOYMENT_NAME}-{INSTANCE_NAME}
spec:
  priority: 110         # Priority to merge the additional config with the default one generated by the chart
  nwis:
  - name: epc2
    ipv4TableID: 100
    ipv6TableID: 100
  - name: epc3
    ipv4TableID: 100
    ipv6TableID: 100
```

Then, apply the YAML file with the UPGConfig CR to the cluster using this command:

```bash
kubectl apply -f {FILENAME}.yaml
```

## Create NADs

To configure NWI IPs, create additional Network Attachment Definitions outside of the UPG chart and apply them to the cluster:

```yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: pgw-u-epc2-inst01
spec:
  config: |-
    {
      "cniVersion": "0.3.1",
      "ipam": {
        "addresses": [
          {
            "address": "198.51.100.1/24"
          }
        ],
        "type": "static"
      },
      "mtu": 8930,
      "name": "grx2",
      "table": 100,
      "type": "fpp-cni",
      "vni": 2150,
      "vppIfaceType": "memif"
    }
---
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: pgw-u-epc3-inst01
spec:
  config: |-
    {
      "cniVersion": "0.3.1",
      "ipam": {
        "addresses": [
          {
            "address": "203.0.113.1/24"
          }
        ],
        "type": "static"
      },
      "mtu": 8930,
      "name": "grx3",
      "table": 100,
      "type": "fpp-cni",
      "vni": 2151,
      "vppIfaceType": "memif"
    }
```

The NADs `pgw-u-epc2-inst01` and `pgw-u-epc3-inst01` is used in the chart configuration `instances.{NAME}.networking.additionalNetworks`.

## Configure the UPG chart

Add the configuration created in previous steps to the UPG Helm chart configuration:

```yaml
instances:
  inst01:
    additionalConfig:
    - upf gtpu endpoint ip 198.51.100.1 nwi epc2 teid 0x80000000/2
    - upf gtpu endpoint ip 203.0.113.1 nwi epc3 teid 0x80000000/2
    networking:
      additionalNetworks:
      - pgw-u-epc2-inst01
      - pgw-u-epc3-inst01
    grx: (...)
    sx: (...)
    sgi: (...)
```

The **additionalNetworks** parameter adds the NADs created for NWI IPs to UPG deployment network annotations. NWIs created in UPGConfig are used to create the GTP-U endpoint in the UPF CLI `upf gtpu endpoint ...` in `instances.{NAME}.additionalConfig`.

Then, install UPG using this command:

```bash
helm upgrade --install {HELM_DEPLOYMENT_NAME} cennso/upg -f ./{FILENAME}.yaml  -n {UPG_NAMESPACE}
```

The `{HELM_DEPLOYMENT_NAME}` must match the UPGConfig label `fpp-manager.cennso.com/plumbing-instance: upg-inst01`, so that the additional configuration is applied on UPG. In this example, `{HELM_DEPLOYMENT_NAME}` is equal to `upg`.

## Verify the configuration

You can check if the requested changes are applied on UPG using the `vppctl` command in the UPG pod:

```bash
vppctl show interface address
```

See the output example:

```bash
grx1 (up):
  L3 198.18.0.20/24 ip4 table-id 100 fib-idx 1
grx2 (up):
  L3 198.51.100.1/24 ip4 table-id 100 fib-idx 1
grx3 (up):
  L3 203.0.113.1/24 ip4 table-id 100 fib-idx 1
local0 (dn):
sgi (up):
  L3 198.19.0.20/24 ip4 table-id 200 fib-idx 2
sxb (up):
  L3 172.20.0.20/24
upf-nwi-cp (up):
upf-nwi-epc2 (up):
upf-nwi-epc3 (up):
upf-nwi-epc (up):
upf-nwi-sgi (up)
```

To see the NWIs configuration, type `vppctl sh upf nwi`. This is the output example:

```bash
cp, ip4-table-id 0, ip6-table-id 0, ipfix-policy none, ipfix-collector-ip 0.0.0.0
epc, ip4-table-id 100, ip6-table-id 100, ipfix-policy none, ipfix-collector-ip 0.0.0.0
sgi, ip4-table-id 200, ip6-table-id 200, ipfix-policy none, ipfix-collector-ip 0.0.0.0
epc2, ip4-table-id 100, ip6-table-id 100, ipfix-policy none, ipfix-collector-ip 0.0.0.0
epc3, ip4-table-id 100, ip6-table-id 100, ipfix-policy none, ipfix-collector-ip 0.0.0.0
```
