> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/netcap/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/cennso/netcap/latest/technical-reference/helm-charts/netcap-chart-config.md).

# NetCap chart configuration

You can configure NetCap using Helm chart configurable parameters. Such configuration allows you to:

- Configure NATS connectivity, including server URL, user credentials, cluster name, and JetStream domain name
- Define the stream’s source and destination
  - Memif socket and targets
  - NATS: subject, server URL override, mode (`jetstream` or `pubsub`)
  - PCAP file options: file prefix, rotation options (maximum number of packets, time, or size), and file compression
- Deploy Prometheus services for metrics capturing
- Configure RClone as a side-container for PCAP transferring

## General configuration

These are the general parameters that you can configure:

| Key | Type | Default | Description |
|---|---|---|---|
| annotations | object | `{}` | Additional annotations for all resources except for the DaemonSet's pods. |
| imagePullSecrets | list | `[]` | `imagePullSecrets` used for pulling the images. Sample value: `[{name: "regcred"}]`. |
| labels | object | `{}` | Additional labels for all resources except for the DaemonSet's pods | |
| podAnnotations | object | `{}` | Additional annotations for pods |
| podLabels | object | `{}` | Additional labels only for pods |
| prometheus.enabled | bool | `true` | Enables the Kubernetes service for the metrics endpoint |
| prometheus.servicemonitor.enabled | bool | `true` | Enables Kubernetes ServiceMonitor |
| rclone.enabled | bool | `false` | Enables Rclone data synchronization |
| rclone.image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. The possible values are: `Always`, `IfNotPresent`, and `Never`. |
| rclone.image.repository | string | `"registry.cennso.com/cennso/docker-rclone"` | Repository where the Docker Rclone's image is stored |
| rclone.image.tag | string | `"v1.60.1-sec.2"` | Image tag |
| rclone.instances | list | `[]` | Rclone instances to deploy as additional containers |
| rclone.path | string | `"/data"` | Filesystem path where the PCAP volume is mounted |
| rclone.resources.limits.cpu | string | `"50m"` | CPU limit for the RClone container. |
| rclone.resources.limits.memory | string | `"256Mi"` | Memory limit for the RClone container. |
| rclone.resources.requests.cpu | string | `"50m"` | CPU request for the RClone container. |
| rclone.resources.requests.memory | string | `"64Mi"` | Memory request for the RClone container. |
| rclone.storageSpec | object | `{"emptyDir":{"sizeLimit":"10Gi"}}` | Specifies custom storage for NetCap Sink's PCAP files when `rclone.enabled=true`. This storage replaces the default PCAP storage. Ensure the configured size can hold all PCAP files for all targets. |

## NetCap Collector configuration

You can configure NetCap Collector with these chart configuration parameters:

| Key | Type | Default | Description |
|---|---|---|---|
| netcapCollector.additionalLabels | object | `{}` | Additional labels for all resources created for NetCap Collector |
| netcapCollector.affinity | object | `{}` | Assigns custom affinity rules to NetCap Collector. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node). |
| netcapCollector.enabled | bool | `true` | Enables NetCap Sink DaemonSet deployment |
| netcapCollector.envs | list | `[]` | Custom environment variables for the NetCap container. Sample value: `[{"name":"APP_EXAMPLE_NAME","value":"APP_EXAMPLE_VALUE"}]` |
| netcapCollector.image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. The possible values are: `Always`, `IfNotPresent`, and `Never`. |
| netcapCollector.image.repository | string | `"registry.cennso.com/cennso/netcap-sink"` | Repository where the NetCap Sink's image is stored |
| netcapCollector.image.tag | string | `""` | Overrides the image tag, which defaults to the chart appVersion. |
| netcapCollector.logLevel | string | `"info"` | Log level. The possible values: `panic`, `fatal`, `error`, `warn`, `info`, `debug`, `trace`. |
| netcapCollector.nats | object | `{"clusterName":"","configBucketName":"netcap-config","controlJetStreamDomain":"","controlNATS":{"url":"nats://nats.default","userCredentials":""},"dataNATS":{"url":"nats://nats.default","userCredentials":""},"statusBucketName":"netcap-status"}` | NATS configuration |
| netcapCollector.nats.clusterName | string | `""` | Cluster name used for NATS subject generation. If empty, the cluster name is taken from the NATS connection info. |
| netcapCollector.nats.configBucketName | string | `"netcap-config"` | Name of NATS Key-Value bucket used for reading the stream configuration |
| netcapCollector.nats.controlJetStreamDomain | string | `""` | Name of the NATS JetStream domain used for Key Value store. If empty, it is not used. |
| netcapCollector.nats.controlNATS | object | `{"url":"nats://nats.default","userCredentials":""}` | Defines Control NATS connectivity for Key Value configurations |
| netcapCollector.nats.controlNATS.url | string | `"nats://nats.default"` | Defines connection URL |
| netcapCollector.nats.controlNATS.userCredentials | string | `""` | Name of the Secret with the NATS user credentials file. If empty, it is not used. |
| netcapCollector.nats.dataNATS | object | `{"url":"nats://nats.default","userCredentials":""}` | Defines Data NATS connectivity for PCAP streams |
| netcapCollector.nats.dataNATS.url | string | `"nats://nats.default"` | Defines connection URL |
| netcapCollector.nats.dataNATS.userCredentials | string | `""` | Name of the Secret with the NATS user credentials file. If empty, it is not used. |
| netcapCollector.nats.statusBucketName | string | `"netcap-status"` | Name of NATS Key-Value bucket used for sending the stream and destination status |
| netcapCollector.nodeSelector | object | `{}` | Selects nodes where the NetCap Sink should run. For more information about nodeSelectors, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). |
| netcapCollector.resources.cpu | string | `"500m"` | CPU assigned to the NetCap container. For more information about resource assignment, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers). |
| netcapCollector.resources.memory | string | `"256Mi"` | Memory assigned to the NetCap container. For more information about resource assignment, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers). |
| netcapCollector.streams | list | `[{"destinations":[],"source":{"memif":{"targets":["pfcp"]}}}]` | List of streams |
| netcapCollector.streams[0] | object | `{"destinations":[],"source":{"memif":{"targets":["pfcp"]}}}` | Stream source from which data is fetched |
| netcapCollector.streams[].destinations | list | `[]` | List of destinations where the stream source will be sent. A destination can include a PCAP file or NATS. |
| netcapCollector.streams[0].destinations[].file | object | `{}` | Configuration of a PCAP destination file |
| netcapCollector.streams[0].destinations[].file.compress | string | `""` | Defines compression algorithm. The available options are: `none`, `zstd`, `lz4`, `gzip`. |
| netcapCollector.streams[0].destinations[].file.compressLevel | int | `0` | Defines compression level. The value depends on the algorithm defined in **netcapCollector.streams[0].destinations[].file.compress**. |
| netcapCollector.streams[0].destinations[].file.max_bytes | int | `0` | Total packet size limit that triggers file rotation |
| netcapCollector.streams[0].destinations[].file.max_files | int | `0` | Limit on the total number of files when rotation is enabled. |
| netcapCollector.streams[0].destinations[].file.max_packets | int | `0` | Limit on the number of packets to trigger file rotation. |
| netcapCollector.streams[0].destinations[].file.rotate | bool | `false` | Enables file rotation. |
| netcapCollector.streams[0].destinations[].file.schedule | string | `""` | Defines a rotation schedule using cron expressions. Examples: `10s`, `@every 1h30m`, `@hourly` and `"30 * * * *"` |
| netcapCollector.streams[0].destinations[].local.prefix | string | `""` | Prefix for autogenerated file names. |
| netcapCollector.streams[0].destinations[].nats | object | `{}` | Configuration of NATS destination. |
| netcapCollector.streams[0].destinations[].nats.batchSize | int | `0` | Defines the maximum number of packets in each NATS message. |
| netcapCollector.streams[0].destinations[].nats.headers | string | `""` | A key/value pair included in the NATS header message. Example: `{apn: test.cennso.com, test-line: line-4}`. |
| netcapCollector.streams[0].destinations[].nats.subject | string | `""` | Defines a subject for NATS message publishing. Example: `pcaps.{CLUSTER}.{TARGET}` |
| netcapCollector.streams[0].destinations[].nats.url | string | `` | NATS connection URL. |
| netcapCollector.streams[0].source.memif | object | `{"targets":["pfcp"]}` | If set, it specifies that the PCAP stream is collected from the connected VPP instance. |
| netcapCollector.streams[0].source.memif.targets | list | `["pfcp"]` | List of targets defined in VPP instance that the stream will capture |
| netcapCollector.tolerations | list | `[]` | Kubernetes tolerations. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration). |

You can reload the NetCap Collector configuration at runtime. The configuration is stored in a ConfigMap. When you apply a new configuration, the ConfigMap content is updated inside the NetCap pod. It can take up to 1 minute for changes to propagate. NetCap checks the local file at regular intervals. If the content has changed since the last update, NetCap parses the new configuration and restarts the affected threads to apply the changes.

See the NetCap Collector configuration example that creates four threads, one for each pair of source and destination:

```yaml
imagePullSecrets:
- name: cur-secret
netcapCollector:
  enabled: true
  logLevel: trace
  nats:
    controlNATS:
      url: "nats://cdm-local.cennso-system:4222"
    dataNATS:
      url: "nats://cdm-local.cennso-system:4222"
    clusterName: "test-cluster"
  streams:
  - source:
      memif:
        targets: [pgw-pfcp]
    destinations:
    - file:
        rotate: true
        max_packets: 100000
        max_files: 2
        compress: zstd
      local:
        prefix: pfpc
    - nats:
        enabled: true
        headers:
          apn: test.cennso.com
          test-line: line-4
  - source:
      memif:
        targets: [sgi]
    destinations:
    - nats:
        subject: "pcaps.{CLUSTER}.{TARGET}"
  - source:
      memif:
        targets: [cgw-apn]
    destinations:
    - file:
        max_packets: 100000
        compress: zstd
      local:
        prefix: cgw
  tolerations:
  - effect: NoSchedule
    key: node-role.cennso.net/dataplane
    value: "true"
```

In the example above, traffic from the target `pgw-pfcp` is saved to a PCAP file and sent to NATS. The PCAP file is stored in the NetCap Collect pod, in the location specified in the **local.prefix** field. Each PCAP file can hold 100,000 packets; a new file is created once this limit is reached. Rotation is enabled, so only two files will be kept. When the limit is reached, the older file is deleted. This means that traffic is collected continuously, but data is lost after 200,000 packets. NATS messages are sent with the subject:

```
cdm.local.netcap.v1alpha1.bcast.pcaps.cluster.{CLUSTER}.namespace.{NAMESPACE}.pod.{POD}.interface.{INTERFACE}.nwi.{NWI}.imsi.{IMSI}.filter.{FILTER}.target.{TARGET}.labels
```

The NATS URL is defined in the global configuration **netcapCollector.nats.dataNATS.url** as `nats://cdm-local.cennso-system:4222`.

Target `sgi` is sent only through NATS to NetCap Sink.

The last target, `cgw-apn`, is saved only to the local disk. The PCAP file is stored in the NetCap Collector pod at the location specified by the **local.prefix** field. It will collect up to 100,000 packets; after that, traffic will not be saved.

You can copy a PCAP file from the pod to an external machine for further analysis. For example, you can use this command:

```bash
kubectl cp -n {NETCAP_COLLECTOR_NS} {NETCAP_COLLECTOR_POD}:/root/dumps/pfcp_2024-11-13T16:35:19.961206426Z.pcapng.zstd ./trace-file.pcapng.zstd
```

## NetCap Sink configuration

You can configure NetCap Sink with these chart configuration parameters:

| Key | Type | Default | Description |
|---|---|---|---|
| netcapSink.additionalLabels | object | `{}` | Additional labels for all resources created for NetCap Sink |
| netcapSink.affinity | object | `{}` | Assigns custom affinity rules to NetCap Sink. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node). |
| netcapSink.enabled | bool | `true` | Enables the NetCap Sink StatefulSet |
| netcapSink.envs | list | `[]` | Custom environment variables for the NetCap container. Sample value: `[{"name":"APP_EXAMPLE_NAME","value":"APP_EXAMPLE_VALUE"}]` |
| netcapSink.image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. The possible values are: `Always`, `IfNotPresent`, and `Never`. |
| netcapSink.image.repository | string | `"registry.cennso.com/cennso/netcap-sink"` | Repository where the NetCap Sink's image is stored |
| netcapSink.image.tag | string | `""` | Overrides the image tag, which defaults to the chart appVersion. |
| netcapSink.logLevel | string | `"info"` | Log level. The possible values are: `panic`, `fatal`, `error`, `warn`, `info`, `debug`, `trace`. |
| netcapSink.nats | object | `{"clusterName":"","configBucketName":"netcap-config","controlJetStreamDomain":"","controlNATS":{"url":"nats://nats.default","userCredentials":""},"dataJetStreamConfig":{"max_bytes":10737418240,"max_msgs":-1},"dataJetStreamName":"cdm-pcaps","dataNATS":{"url":"nats://nats.default","userCredentials":""},"manageDataJetStream":false,"statusBucketName":"netcap-status"}` | NATS configuration |
| netcapSink.nats.clusterName | string | `""` | Name of the cluster, used for cluster identification in durable consumer name |
| netcapSink.nats.configBucketName | string | `"netcap-config"` | Name of NATS Key-Value bucket used for reading the stream configuration |
| netcapSink.nats.controlJetStreamDomain | string | `""` | Name of the NATS JetStream domain used for Key Value store. If empty, it is not used. |
| netcapSink.nats.controlNATS | object | `{"url":"nats://nats.default","userCredentials":""}` | Defines Control NATS connectivity for Key Value configurations |
| netcapSink.nats.controlNATS.url | string | `"nats://nats.default"` | Defines connection URL |
| netcapSink.nats.controlNATS.userCredentials | string | `""` | Name of the Secret with the NATS user credentials file. If empty, it is not used. |
| netcapSink.nats.dataJetStreamConfig | object | `{"max_bytes":10737418240,"max_msgs":-1}` | JetStream configuration for PCAPs transfer |
| netcapSink.nats.dataJetStreamConfig.max_bytes | int | `10737418240` | Stream capacity in bytes. By default: 10GiB |
| netcapSink.nats.dataJetStreamConfig.max_msgs | int | `-1` | Integer number for defining how many messages can be stored in a stream. By default unlimited (-1). |
| netcapSink.nats.dataJetStreamName | string | `"cdm-pcaps"` | JetStream name used for PCAPs transfer |
| netcapSink.nats.dataNATS | object | `{"url":"nats://nats.default","userCredentials":""}` | Defines Data NATS connectivity for PCAP streams |
| netcapSink.nats.dataNATS.url | string | `"nats://nats.default"` | Defines a connection URL |
| netcapSink.nats.dataNATS.userCredentials | string | `""` | Name of the Secret with the NATS user credentials file. If empty, it is not used. |
| netcapSink.nats.manageDataJetStream | bool | `false` | Enables JetStream creation, the NATS JetStream defined in nats.dataJetStreamConfig will be created |
| netcapSink.nats.statusBucketName | string | `"netcap-status"` | Name of NATS Key-Value bucket used for sending the stream and destination status |
| netcapSink.nodeSelector | object | `{}` | Selects nodes where NetCap Sink should run. For more information about nodeSelectors, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). |
| netcapSink.resources.cpu | string | `"500m"` | CPU assigned to the NetCap container. For more information about resource assignment, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers). |
| netcapSink.resources.memory | string | `"256Mi"` | Memory assigned to the NetCap container. For more information about resource assignment, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers). |
| netcapSink.sshPrivKeys | object | `{}` | SSH private keys used to access the remote storage. Each entry maps a key name to a PEM-encoded private key. NetCap Sink mounts these keys at `/etc/ssh-keys/fromValues`. |
| netcapSink.sshPrivKeysFromSecrets | list | `[]` | Names of Kubernetes Secrets that hold SSH private keys used to access the remote storage. NetCap Sink mounts each Secret at `/etc/ssh-keys/{SECRET_NAME}`. |
| netcapSink.streams | list | `[{"destinations":[],"source":{"nats":{"mode":"pubsub","name":"debug","subject":"pcaps.*","url":"nats://nats.default"}}}]` | List of streams |
| netcapSink.streams[] | object | `{"destinations":[],"source":{"nats":{"mode":"pubsub","name":"debug","subject":"pcaps.*","url":"nats://nats.default"}}}` | Stream source from which data is fetched |
| netcapSink.streams[].destinations | list | `[]` | List of destinations where the stream source will be sent. Destinations can include a PCAP file. |
| netcapSink.streams[0].destinations[].file | object | `{}` | Configuration of a PCAP destination file |
| netcapSink.streams[0].destinations[].file.compress | string | `""` | Defines compression algorithm. The available options are: `none`, `zstd`, `lz4`, `gzip`. |
| netcapSink.streams[0].destinations[].file.compressLevel | int | `0` | Defines compression level. The value depends on the algorithm defined in **netcapSink.streams[0].destinations[].file.compress**. |
| netcapSink.streams[0].destinations[].file.max_bytes | int | `0` | Total packet size limit that triggers file rotation |
| netcapSink.streams[0].destinations[].file.max_files | int | `0` | Limit on the total number of files before triggering rotation |
| netcapSink.streams[0].destinations[].file.max_packets | int | `0` | Limit on the number of packets to trigger file rotation. |
| netcapSink.streams[0].destinations[].file.rotate | bool | `false` | Enables file rotation. |
| netcapSink.streams[0].destinations[].file.schedule | string | `""` | Defines a rotation schedule using cron expressions, examples: `10s`, `@every 1h30m`, `@hourly` and `"30 * * * *"` |
| netcapSink.streams[0].destinations[].local.prefix | string | `false` | Defines prefix for autogenerated PCAP file name. |
| netcapSink.streams[0].source.nats | object | `{"mode":"pubsub","name":"debug","subject":"pcaps.*","url":"nats://nats.default"}` | If specified, a PCAP stream is fetched from NATS. |
| netcapSink.streams[0].source.nats.mode | string | `"pubsub"` | Specifies a NATS mode, either `pubsub` or `jetstream`. |
| netcapSink.streams[0].source.nats.name | string | `"debug"` | Name of the aggregated PCAP stream, used for attaching an HTTP endpoint |
| netcapSink.streams[0].source.nats.subject | string | `"pcaps.*"` | In the `pubsub` mode, NetCap Sink listens to messages on the specified subject, which can include wildcards (`*` or `>`). The subject is also used for attaching an HTTP endpoint. |
| netcapSink.streams[0].source.nats.url | string | `"nats://nats.default"` | NATS connection URL |
| netcapSink.tolerations | list | `[]` | Kubernetes tolerations. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration). |
| netcapSink.volumeMounts | list | `[]` | Additional volume mounts for the NetCap Sink container. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/volumes). |
| netcapSink.volumes | list | `[]` | Additional volumes for the NetCap Sink pod. For more information, read the official [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/volumes). |

See the NetCap Sink configuration example that creates one thread for fetching the PCAP data from NATS to the `.pcapng` file:

```yaml
imagePullSecrets:
- name: cur-secret
netcapSink:
  enabled: true
  logLevel: trace
  nats:
    clusterName: test-cluster
    controlNATS:
      url: "nats://cdm-local.cennso-system:4222"
    dataNATS:
      url: "nats://cdm-local.cennso-system:4222"
    controlJetStreamDomain: mc
    dataJetStreamName: pcaps-test-cluster
    manageDataJetStream: true
    dataJetStreamConfig:
      subjects:
        - pcaps.test-cluster.>
      max_bytes: 1073741824
  streams:
  - source:
      nats:
        name: debug
        mode: jetstream
        subject: "pcaps.test-cluster.*"
    destinations:
    - file:
        rotate: true
        max_packets: 100000
        max_files: 10
        compress: zstd
      local:
        prefix: pfcp
  tolerations:
  - effect: NoSchedule
    key: node-role.cennso.net/dataplane
    value: "true"
```

NetCap Sink has JetStream management enabled, so it will create a JetStream named `pcaps-test-cluster` with the following settings:

- Messages sent to the subject `pcaps.test-cluster.>` will be stored in the stream.
- The maximum size for stored messages is 1 GiB (1,073,741,824 bytes).

The source is configured to use NATS in the JetStream mode, which means that NetCap Sink creates a [durable NATS consumer](https://docs.nats.io/learn/jetstream/pull-consumers). This allows the Sink to fetch all stored messages from the NATS server, even if the NetCap Sink is offline. In the `pubsub` mode, the Sink can only fetch messages sent while it is online, so any previous data is lost.

The `source.nats.name` is used to identify the HTTP endpoint attachment. The name must be unique in the NetCap Sink configuration; otherwise, only the first matching source will be used when attaching with Wireshark. To live-debug the PCAPs, use Wireshark:

```bash
curl --compressed localhost:9999/pcap/debug -N | wireshark -k -i - -o 'gui.window_title:netcap-stream' -o 'capture.no_interface_load:TRUE'
```

The destination is of `file` type, typically used to store PCAPs sent over NATS to a file.
