Traffic capturing and exposure
This document explains how to capture traffic using PCAP configuration and how to publish the captured traffic using rclone.
Capture traffic
To capture traffic in a pod, enable pcap and configure it using environment variables as described in the PCAP container documentationOpens in a new tab:
Expose traffic
To publish traffic captured in the PCAP container, enable rclone and configure it using environment variables. Use RCLONE_REMOTE_NAME to specify the remote endpoint and RCLONE_REMOTE_PATH to specify the 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 documentationOpens in a new tab. The inotifyOpens in a new tab pattern watches for captures and moves them from the /data/finished directory.
You can configure Rclone to use different storage providers. The sections below provide examples on how to configure SFTP and S3 storage providers.
SFTP with password authentication
This container configuration example enables authentication for SFTP through username and password:
SFTP with private key authentication
You can also authenticate SFTP using private keys. To do so, set the useSSHkeyFile parameter to true.
See the configuration example:
In this case, the rclone-ssh-secret secret is mounted to the /etc/ssh directory in a namespace with the rclone container. The secret name is specified through the RCLONE_CONFIG_SFTP_KEY_FILE environment variable. The rclone-ssh-key secret is not created automatically when deploying the Helm chart. You must prepare it manually. To do so, run this command:
S3 storage provider
This container configuration example enables authorization for S3 through access-key and secret-access-key:
If RCLONE_CONFIG_S3_ENV_AUTH is set to false, the access_key_id and secret_access_key must be provided in the rclone configuration file. Otherwise, RCLONE_CONFIG_S3_ACCESS_KEY_ID and RCLONE_CONFIG_S3_SECRET_ACCESS_KEY environment variables are used. For more information, read rclone S3 authentication guideOpens in a new tab.
The rclone moveOpens in a new tab command moves PCAP files out of the source path data/finished. This keeps the containers memory consumption manageable and enables file rotation. If the process crashes during files transfer, no data from the transferred files remains on the destination address. Also, the container log shows the Terminated status. If the files are duplicated in the source and destination path, the duplicated files are removed from the source path but not modified on the destination if MD5/SHAOpens in a new tab checksums and filenames are the same on both sides.
Caution
If you lose access to the destination, the conditions described above can cause data loss. Consider testing first using the --dry-run flag.