Skip to content

feat(azure): support Azure workload identity via projected service account token#816

Open
rkthtrifork wants to merge 1 commit intocloudnative-pg:mainfrom
rkthtrifork:rkth/azure-workload-identity
Open

feat(azure): support Azure workload identity via projected service account token#816
rkthtrifork wants to merge 1 commit intocloudnative-pg:mainfrom
rkthtrifork:rkth/azure-workload-identity

Conversation

@rkthtrifork
Copy link

@rkthtrifork rkthtrifork commented Mar 17, 2026

Summary

This PR adds Azure workload identity support for plugin-managed CNPG sidecars by projecting a service account token with the Azure audience into the sidecar pod when azureCredentials.useDefaultAzureCredentials: true is configured.

This keeps the existing AKS managed identity flow unchanged:

  • inheritFromAzureAD: true still uses the managed identity / IMDS path
  • useDefaultAzureCredentials: true now supports workload identity by exposing AZURE_FEDERATED_TOKEN_FILE and the projected token to DefaultAzureCredential

Changes

  • detect whether any referenced ObjectStore uses useDefaultAzureCredentials
  • inject a projected service account token volume into the plugin sidecar pod
  • set AZURE_FEDERATED_TOKEN_FILE for the sidecar
  • preserve existing user/webhook-provided Azure env vars
  • add unit tests for:
    • workload identity detection
    • sidecar token volume/env injection
    • preserving an existing AZURE_FEDERATED_TOKEN_FILE
  • update Azure object store docs to describe the workload identity path

Behavior

With this change:

  • useDefaultAzureCredentials: true
    the plugin sidecar gets:

    • a projected token with audience api://AzureADTokenExchange
    • AZURE_FEDERATED_TOKEN_FILE=/var/run/secrets/azure/tokens/azure-identity-token
  • inheritFromAzureAD: true
    behavior is unchanged and no federated token volume is injected

This means clusters using the older implicit AKS managed identity flow remain supported, while clusters using Azure workload identity can now work without relying on an external injector to provide the token file.

@rkthtrifork rkthtrifork requested a review from a team as a code owner March 17, 2026 08:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 17, 2026
@rkthtrifork rkthtrifork changed the title feat: add Azure workload identity support feat(azure): support workload identity via projected service account token Mar 17, 2026
@rkthtrifork rkthtrifork changed the title feat(azure): support workload identity via projected service account token feat(azure): support Azure workload identity via projected service account token Mar 17, 2026
Signed-off-by: rkthtrifork <rkth@trifork.com>
@rkthtrifork rkthtrifork force-pushed the rkth/azure-workload-identity branch from 1faa68d to 2a70f54 Compare March 17, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant