> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/3.10/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/smc/3.10/operation/traffic-capture.md).

# Traffic Capture and Exposure

To publish traffic captured by the pcap container, you have to enable `rclone` along `pcap` and
configure it using environmental variables. Use `RCLONE_REMOTE_NAME` to use
the correct remote and `RCLONE_REMOTE_PATH` for the correct destination path.
`Rclone` is defined generically through the container environment.
To find the name of the environment variable, first, take the long option name,
strip the leading --, change - to _ make upper case and prepend RCLONE_.
All available endpoints are described in the [official rclone documentation](https://rclone.org/commands/rclone_move/).
An [inotify](https://linux.die.net/man/1/inotifywait) pattern is watching for captures, moving them from the directory `/data/finished`.

This container example-configuration enables authorisation for SFTP through username and password:

```yaml
rclone:
  enabled: true
  env:
    RCLONE_REMOTE_NAME: "sftp" # Mandatory, when defining multiple devices, this is your selector.
    RCLONE_CONFIG_SFTP_TYPE: "sftp"
    RCLONE_CONFIG_SFTP_HOST: "host.com" # hostname or ip of sftp-server
    RCLONE_CONFIG_SFTP_USER: "name"
    RCLONE_CONFIG_SFTP_PORT: "22"
    RCLONE_CONFIG_SFTP_PASS: "password" # Encoded "password". Leave blank to use ssh-agent
```

SFTP can also be authorised using private keys. Setting `useSSHkeyFile` will look for
the secret which name is configured by `.Values.rclone.secretName` in the appropriate namespace and mount it to `/etc/ssh` in
the container's filesystem. Rclone will look for the file using `RCLONE_CONFIG_SFTP_KEY_FILE` -
environment variable.

```yaml
rclone:
  enabled: true
  useSSHkeyFile: true
  env:
    RCLONE_REMOTE_PATH: "name/directory"
    RCLONE_REMOTE_NAME: "sftp" # Mandatory,
    RCLONE_CONFIG_SFTP_TYPE: "sftp"
    RCLONE_CONFIG_SFTP_HOST: "host.com" # hostname or ip of sftp-server
    RCLONE_CONFIG_SFTP_USER: "name"
    RCLONE_CONFIG_SFTP_PORT: "22"
    RCLONE_CONFIG_SFTP_PASS: "" # Encoded, blank for agent.
    RCLONE_CONFIG_SFTP_KEY_FILE: "/etc/ssh/key.pem"
```
Note that this secret `.Values.rclone.secretName` is not created automatically when deploying this helm chart, but needs
to be manually prepared by the user like so:

```bash
kubectl create secret generic rclone-ssh-key --from-file=/path/to/key.pem -n <namespace>
```

This container example-configuration enables authorisation for s3 through access-key and secret-access-key:

```yaml
rclone:
  enabled: true
  env:
    RCLONE_CONFIG_S3_TYPE: "s3"
    RCLONE_CONFIG_S3_ENV_AUTH: "false"
    RCLONE_CONFIG_S3_ACCESS_KEY_ID: "<sensitive>"
    RCLONE_CONFIG_S3_SECRET_ACCESS_KEY: "<sensitive>"
    RCLONE_CONFIG_S3_REGION: "s3-<region>"
    RCLONE_CONFIG_S3_ACL: "private"
    RCLONE_CONFIG_S3_FORCE_PATH_STYLE: "false"
```

Note that using `rclone_move` implies that transferred files will be removed from
the source path `data/finished`. This keeps the container's memory-footprint manageable
and enables file-cycling. If the process crashes during transfer no garbage data will remain
on the destination address and you will notice a `Terminated` in the container logs.
When attempting to push duplicate files they will be removed from the source path but
not overwritten/modified on the destination if [MD5/SHA](https://github.com/ncw/rclone#features)
checksums and file-name are the same on both ends.
Be aware this can cause data loss, if you were to lose the access to the data at
the destination. Consider testing first using the `--dry-run` flag.

## Trace configuration

| Parameter | Description | Default |
|---|---|---|
| smc.containers.pcap.enabled | Enables/Disables container | false |
| smc.containers.pcap.image.pullPolicy | | IfNotPresent |
| smc.containers.pcap.image.tag | Image version | v1.2.1 |
| smc.containers.pcap.image.repository | Image | quay.io/travelping/pcap |
| smc.containers.pcap.iface | Interface to monitor | |
| smc.containers.pcap.maxfilenum | Max number of files before overwriting | |
| smc.containers.pcap.maxfilesize | Max files size before overwriting, Megabytes | |
| smc.containers.pcap.volume | Directory where to store PCAP files | |
| smc.containers.rclone.enabled | Enables/Disables container | false |
| rclone.env.RCLONE_CONFIG_S3_FORCE_PATH_STYLE | Environment variable | false |
| rclone.env.RCLONE_CONFIG_S3_ACL | Environment variable | private |
| rclone.env.RCLONE_REMOTE_NAME | Environment variable | s3 |
| rclone.env.RCLONE_CONFIG_S3_TYPE | Environment variable | s3 |
| rclone.env.RCLONE_CONFIG_S3_SECRET_ACCESS_KEY | Environment variable | |
| rclone.env.RCLONE_CONFIG_S3_ENV_AUTH | Environment variable | false |
| rclone.env.RCLONE_CONFIG_S3_REGION | Environment variable | eu-central-1 |
| rclone.image.pullPolicy | | IfNotPresent |
| rclone.image.tag | Image version | v1.50.2 |
| rclone.image.repository | Image | quay.io/travelping/docker-rclone |
| rclone.envtpl.RCLONE_REMOTE_PATH | | pcap-traces/{{ template "gpc.fullname" . }} |
