Skip to content

CP-40648: Add CSI secret provider support for API key delivery#819

Open
evan-cz wants to merge 2 commits into
developfrom
CP-40648
Open

CP-40648: Add CSI secret provider support for API key delivery#819
evan-cz wants to merge 2 commits into
developfrom
CP-40648

Conversation

@evan-cz
Copy link
Copy Markdown
Contributor

@evan-cz evan-cz commented May 18, 2026

Community PR #772 added generic extraVolumes/extraVolumeMounts to support CSI-driven API key delivery from external vaults. The approach was too broad — it coupled generic volume mounting to credential validation and
exposed the API key volume to every workload regardless of need. This replaces that with a single components.apiKey.secretProviderClass property that switches the API key volume source from a Kubernetes Secret to a Secrets Store CSI Driver volume.

Functional Requirements:

  1. Users must be able to mount the API key via the Secrets Store CSI Driver without creating a Kubernetes Secret object.

    Added components.apiKey.secretProviderClass. When set (and both top-level apiKey and existingSecretName are null), the chart generates a CSI volume using the secrets-store.csi.k8s.io driver instead of a Kubernetes Secret volume. The mount path (serverConfig.containerSecretFilePath) is unchanged.

  2. Existing apiKey and existingSecretName must continue to work and take priority.

    The top-level properties are not deprecated or relocated. A new cloudzero-agent.apiKey.mode helper resolves the active provisioning mode (inline, secret, csi, or none) and is used by the volume mount, volume definition, and volumes-section guards.

  3. The volume definition must not be duplicated across templates.

    Added a cloudzero-agent.apiKeyVolume helper that generates the correct volume definition (Secret or CSI) based on the resolved mode. This replaced six identical inline volume blocks across agent-deploy, agent-daemonset, aggregator-deploy, webhook-deploy, backfill-job, and config-loader-job templates.

  4. The generic extraVolumes/extraVolumeMounts mechanism must be removed.

    Removed the extraVolumes and extraVolumeMounts values, schema properties, template helpers, and all wiring across the six workload templates. Removed the validateExternalApiKeyMountPath render-time guard since CSI mode no longer depends on extra volume mounts.

Validation:

  • All 565 Helm unit tests pass (schema, template rendering, CSI volume rendering, precedence, and backwards compatibility)
  • Added helm/tests/apikey_csi_volume_test.yaml covering CSI volume rendering across all workload templates
  • Updated helm/tests/apikey_secret_validation_test.yaml with secretProviderClass schema validation and precedence tests
  • Removed helm/tests/api_key_mount_path_validation_test.yaml and helm/tests/extra_volumes_test.yaml (no longer applicable)
  • Deployed and validated end-to-end on EKS (AWS Secrets Manager) and AKS (Azure Key Vault) using the Secrets Store CSI Driver

JoeDerby and others added 2 commits May 14, 2026 09:14
Add extraVolumes and extraVolumeMounts to the chart, enabling external
file-based credential flows (e.g. CSI-driven mounts) without introducing
a new feature toggle. Default chart behaviour is unchanged for existing
users.

New chart values:
- extraVolumes
- extraVolumeMounts

Wired into all relevant workloads: agent-deploy, agent-daemonset,
aggregator-deploy, config-loader-job, webhook-deploy, and backfill-job.
Added reusable Helm helpers for rendering the extra volumes and mounts.

Strengthened schema validation:
- Default mode: exactly one of apiKey or existingSecretName must be set.
- External mode: if both are null, extraVolumes and extraVolumeMounts
  must be non-empty.

Added render-time validation guard: in external mode, at least one
extraVolumeMount.mountPath must match serverConfig.containerSecretFilePath.
This prevents misconfiguration where credentials are mounted but not at
the path the app reads.

Added Helm unit tests for extra volume/mount behaviour, API key source
validation logic, and external mount-path validation.
Community PR #772 added generic extraVolumes/extraVolumeMounts to support
CSI-driven API key delivery from external vaults. The approach was too
broad — it coupled generic volume mounting to credential validation and
exposed the API key volume to every workload regardless of need. This
replaces that with a single components.apiKey.secretProviderClass property
that switches the API key volume source from a Kubernetes Secret to a
Secrets Store CSI Driver volume.

Functional Requirements:

1. Users must be able to mount the API key via the Secrets Store CSI
   Driver without creating a Kubernetes Secret object.

   Added components.apiKey.secretProviderClass. When set (and both
   top-level apiKey and existingSecretName are null), the chart generates
   a CSI volume using the secrets-store.csi.k8s.io driver instead of a
   Kubernetes Secret volume. The mount path
   (serverConfig.containerSecretFilePath) is unchanged.

2. Existing apiKey and existingSecretName must continue to work and take
   priority.

   The top-level properties are not deprecated or relocated. A new
   cloudzero-agent.apiKey.mode helper resolves the active provisioning
   mode (inline, secret, csi, or none) and is used by the volume mount,
   volume definition, and volumes-section guards.

3. The volume definition must not be duplicated across templates.

   Added a cloudzero-agent.apiKeyVolume helper that generates the correct
   volume definition (Secret or CSI) based on the resolved mode. This
   replaced six identical inline volume blocks across agent-deploy,
   agent-daemonset, aggregator-deploy, webhook-deploy, backfill-job, and
   config-loader-job templates.

4. The generic extraVolumes/extraVolumeMounts mechanism must be removed.

   Removed the extraVolumes and extraVolumeMounts values, schema
   properties, template helpers, and all wiring across the six workload
   templates. Removed the validateExternalApiKeyMountPath render-time
   guard since CSI mode no longer depends on extra volume mounts.

Validation:

- All 565 Helm unit tests pass (schema, template rendering, CSI volume
  rendering, precedence, and backwards compatibility)
- Added helm/tests/apikey_csi_volume_test.yaml covering CSI volume
  rendering across all workload templates
- Updated helm/tests/apikey_secret_validation_test.yaml with
  secretProviderClass schema validation and precedence tests
- Removed helm/tests/api_key_mount_path_validation_test.yaml and
  helm/tests/extra_volumes_test.yaml (no longer applicable)
- Deployed and validated end-to-end on EKS (AWS Secrets Manager) and AKS
  (Azure Key Vault) using the Secrets Store CSI Driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants