NetCaptureStorage CR
NetCaptureStorage CR specifies the storage location for collected PCAP files. The supported locations are:
- Local disk
- SFTP server
- S3 storage
The following sections describe all configurable parameters available in the NetCaptureStorage CR. For a step-by-step guide on how to perform the configuration, see the Configure PCAP capturing guide.
Local storage
You can store PCAPs locally in the Core Cluster. In this case, PCAPs are saved on the Kubernetes worker node disk, by default at /root/dumps. This path is mounted into the NetCap Sink pod, so the data stays available even if the pod restarts.
To define a subdirectory of /root/dumps, set spec.forProvider.local.path to your subdirectory name. The resulting local path will be /root/dumps/{SUBDIRECTORY_NAME}.
To configure a local storage:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the Local Storage storage type.
- Enter the path for the subdirectory in the Path text field.
- Click Create to finalize.
Create the following NetCaptureStorage custom resource and apply it to your cluster:
SFTP server
To set an SFTP server as a location for your PCAP files, provide all required connection parameters in the spec.forProvider.sftp configuration section. NetCap uses rcloneOpens in a new tab to connect to an external SFTP server.
You can authenticate to the SFTP server in two ways:
NetCap supports all the rclone connection parameters. For the full set of fields, please take a look at the rclone SFTP documentationOpens in a new tab.
Plain user/password
You can provide the user and password as plain text in the NetCaptureStorage object. Follow the instructions:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the SFTP Server Connection storage type.
- Enter the username for the SSH connection in the User field.
- In the Authentication method fields, choose the Password type.
- Enter a plaintext password in the Password text field.
- Click Create to finalize.
Key-based authentication
You can use SSH keys to authenticate. To do this, provide the private SSH key in one of three ways:
- As an existing Kubernetes Secret
- In the NetCap Sink deployment
- In the spec.forProvider.sftp.credentials.key_pem parameter within the
NetCaptureStorageCR
Define a key as a Kubernetes Secret
You can store a PEM-encoded private key as a Kubernetes secret created in the cennso-system namespace. For example:
The secret name is sftp-admin-privkey with the SSH key stored under the testkey parameter.
Next, install the NetCap extension on a Core Cluster and embed the reference to your secret in the NetCapClusterDeployment resource. Follow the instructions:
- Create a new
NetCap Cluster Deploymentor edit the existing one. - Go to the Specification tab, expand the SSH Keys parameter, and click the + Add button.
- Provide a name for your SSH key in the Name field.
- Enter a PEM-encoded private key in the Value field.
- Click Create to confirm.
Create the following NetCapClusterDeployment custom resource and apply it to your cluster:
Finally, provide a reference to your secret and the content of the private key in NetCaptureStorage:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the SFTP Server Connection storage type.
- Under the Authentication method field, choose the Key File type.
- Enter
sftp-admin-privkey/testkey(a file path to your PEM-encoded private key) in the Key File text box. - Click Create to finalize.
Define a key in the NetCap Sink deployment
You can add a secret private key directly in NetCapClusterDeployment:
- Create a new
NetCap Cluster Deploymentor edit the existing one. - Go to the Specification tab, expand the SSH Keys parameter, and click the + Add button.
- Provide a name for your SSH key in the Name field.
- Enter a PEM-encoded private key in the Value field.
- Click Create to confirm.
The NetCap Sink deployment takes care of creating a Kubernetes secret in the cennso-system namespace.
Next, configure NetCaptureStorage by setting spec.forProvider.sftp.credentials.key_file with fromValues/testkey, for example:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the SFTP Server Connection storage type.
- Under the Authentication method field, choose the Key File type.
- Enter
sftp-admin-privkey/testkey(a file path to your PEM-encoded private key) in the Key File text box. - Click Create to finalize.
Define a key as plain text
Another option is to define the raw PEM-encoded private key in the spec.forProvider.sftp.credentials.key. See the example:
- Create a new
NetCaptureStorageor edit the existing one. - Switch to the Specification tab and choose a SFTP Server Connection storage type.
- Under Authentication method parameter, choose the Key PEM type.
- Paste the plain PEM-encoded private key in the Key PEM text field.
- Click Create to finalize.
Advanced configuration
If you need to pass any additional parameters to your SFTP configuration, use the spec.forProvider.sftp.advanced map. For example:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the SFTP Server Connection storage type.
- Scroll down and expand SFTP Advanced Connection Parameters.
- Click the + Add button and add
keyandvaluefor your advanced options. - Click Create to finalize.
For the full set of fields, take a look at the rclone SFTP documentationOpens in a new tab.
S3 storage
To set S3 as a storage location for your PCAP files, provide all required connection parameters in the spec.forProvider.s3 configuration section. NetCap uses rcloneOpens in a new tab to connect to an external S3 server.
You can provide the S3 credentials in three ways:
- Plain values in the
NetCaptureStorageCR - Kubernetes Secrets
- Environment of the NetCap Sink container
The following example uses plain values:
Configuration parameters
For a detailed description of configuration parameters for S3 connection defined in spec.forProvider.s3, go to the rclone s3Opens in a new tab documentation.
- access_key_idOpens in a new tab
- secret_access_keyOpens in a new tab
- aclOpens in a new tab
- bucket - name where the PCAP files will be uploaded.
- chunk_sizeOpens in a new tab
- endpoint - URL address of S3 server
- providerOpens in a new tab
- regionOpens in a new tab
- server_side_encryptionOpens in a new tab
- storage_classOpens in a new tab
- sse_kms_key_idOpens in a new tab
Read parameters from Kubernetes Secrets
You can read S3 parameters from Kubernetes Secrets created in the Management Cluster and keep plain-text values out of the NetCaptureStorage CR. Use the spec.forProvider.s3.fromSecret list. Each entry in the list sets one S3 parameter from one key of one Secret and takes the following fields:
- name is the S3 parameter to set, for example
access_key_id. - secretRef.name is the name of the Secret that holds the value.
- secretRef.namespace is the namespace of the Secret.
- secretKey is the key inside the Secret data. This field is optional. If you skip it, NetCap Provider uses the value of name as the key.
Create the Secrets on the Management Cluster, in the namespace you set in secretRef.namespace.
Important
Parameters from fromSecret take precedence over the plain-text fields in spec.forProvider.s3. If you set the same parameter in both places, NetCap Provider applies the value from the Secret.
The NetCaptureStorage CRD requires spec.forProvider.s3.endpoint and spec.forProvider.s3.provider. To read the endpoint from a Secret, keep the endpoint field in the CR and set it to an empty value.
NetCap Provider watches the referenced Secrets. When you update a Secret, NetCap Provider reads the new values and updates the traffic capture configuration.
If the Secret or the key does not exist, NetCap Provider reports an error and keeps the previous configuration.
To read S3 parameters from Secrets:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab.
- Choose the S3 storage storage type.
- Expand Parameters From Secrets.
- Click the + Add button.
- In the Parameter field, enter the name of the S3 parameter, for example
access_key_id. - In the Name and Namespace fields under Secret, point to the Secret that holds the value.
- In the Secret Key field, enter the key inside the Secret data. If the key has the same name as the parameter, leave the field empty.
- Repeat steps 5 to 8 for every parameter you want to read from a Secret.
- Click Create to finalize.
NetCap Provider reads the S3 parameters from the Secret on the next reconciliation.
The following NetCaptureStorage Custom Resource reads the endpoint, bucket name, and credentials from the pcap-object-storage-credentials Secret in the cennso-system namespace:
Read credentials from the container environment
Set spec.forProvider.s3.env_auth to true to keep the AWS credentials out of the NetCaptureStorage CR. NetCap Sink then takes them from the environment of its container. It reads the standard AWS credential variables, such as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. When no variables are set, it falls back to instance metadata, which covers deployments that authenticate through an Identity and Access Management (IAM) role.
Important
spec.forProvider.s3.env_auth applies only when spec.forProvider.s3.access_key_id and spec.forProvider.s3.secret_access_key are both empty. If either parameter holds a value, including a value supplied through fromSecret, NetCap Sink uses that value and ignores the environment.
Supply the variables with spec.sinkEnv on the NetCapClusterDeployment CR. Any Secret they reference must exist in the cennso-system namespace of the Core Cluster, where NetCapClusterDeployment deploys NetCap Sink. For the deployment-side configuration, see NetCap Sink environment variables and volumes.
To read the credentials from the container environment:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab.
- Choose the S3 storage storage type.
- Select the Env Auth checkbox.
- Leave the Access Key ID and Secret Access Key fields empty.
- Click Create to finalize.
NetCap Sink takes the credentials from its container environment on the next reconciliation.
The following NetCaptureStorage Custom Resource takes the AWS credentials from the NetCap Sink container environment:
Advanced configuration
If your S3 configuration requires to pass any additional parameters, use the spec.forProvider.s3.advanced map, for example:
- Create a new
NetCapture Storageor edit the existing one. - Switch to the Specification tab and choose the S3 storage storage type.
- Scroll down and expand S3 Advanced Parameters.
- Click the + Add button and add
keyandvaluefor your advanced options. - Click Create to finalize.
For the full set of fields, take a look at the rclone S3 documentationOpens in a new tab.