Cluster fails to start when using Azure AD Workload Identity with Barman plugin
Environment
CNPG Version: v1.26 PostgreSQL Image: ghcr.io/cloudnative-pg/postgresql:17.5-standard-bookworm Barman Plugin Version: 0.5.0 Kubernetes: AKS (with Azure AD Workload Identity)
Goal
I’m trying to configure Barman Cloud Plugin to take backups to Azure Blob Storage using Azure AD Workload Identity (instead of using storage account key credentials).
ObjectStore configuration (with Workload Identity)
kind: ObjectStore
metadata:
name: azure-store
spec:
configuration:
destinationPath: https://akspgdbbackup.blob.core.windows.net/mypgBackup
azureCredentials:
inheritFromAzureAD: true
wal:
compression: gzip
data:
compression: bzip2
retentionPolicy: "3d"
Cluster configuration
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: test-1
namespace: test-namespace
labels:
env: devl
app: test
svc: db
podname: "test-1"
wa: NALA
spec:
instances: 1
imagePullPolicy: Always
imageCatalogRef:
apiGroup: postgresql.cnpg.io
kind: ImageCatalog
name: test-postgres-catalog
major: 17
enableSuperuserAccess: true
imagePullSecrets:
- name: testcregcred
storage:
size: 1Gi
plugins:
- name: barman-cloud.cloudnative-pg.io
isWALArchiver: true
parameters:
barmanObjectName: azure-store
Observed behavior
When I create the cluster, reconciliation fails with the following error:
Pre-reconcile hook stopped the reconciliation loop","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"test-1","namespace":"test-namespace"},"namespace":"test-namespace","name":"test-1","reconcileID":"e00c4983-8c70-45e4-ab3a-32e4bf8bfe6f","hookResult":{"result":{"Requeue":true,"RequeueAfter":0},"err":null,"stopReconciliation":true,"identifier":"barman-cloud.cloudnative-pg.io"}}
no orphan PVCs found, skipping the restored cluster
The cluster remains in a failed reconciliation loop.
Expected behavior
Cluster should initialize successfully and be able to use the configured Azure Blob Storage via Workload Identity
Workaround
If I change the ObjectStore to use storage account credentials instead of Azure AD identity, everything works — the cluster starts and backups are successfully taken.
Working configuration:
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: azure-store
spec:
configuration:
destinationPath: https://akspgdbbackup.blob.core.windows.net/mypgBackup
azureCredentials:
storageAccount:
name: azure-credentials
key: AZURE_STG_ACC
storageKey:
name: azure-credentials
key: AZURE_STG_KEY
wal:
compression: gzip
data:
compression: bzip2
retentionPolicy: "3d"
Question
Is Workload Identity authentication currently supported by the Barman Cloud plugin (v0.5.0)? If yes, could you please clarify what additional configuration or permissions might be required for:
azureCredentials:
inheritFromAzureAD: true
Contact
If you need more details or logs, feel free to reach out to me at [email protected]
Hi @beingvishalt! I'm Dosu and I’m helping the plugin-barman-cloud team.
Yes, Azure AD Workload Identity authentication is supported by the Barman Cloud plugin v0.5.0 for backups to Azure Blob Storage. Your configuration using azureCredentials: inheritFromAzureAD: true is correct for enabling this feature reference.
To make this work, you need to ensure that Azure AD Workload Identity is properly configured in AKS and Kubernetes. This means the pod's ServiceAccount must be annotated with the Azure AD application client ID, and the federated credentials in Azure AD must link to the ServiceAccount using the subject identifier format system:serviceaccount:<namespace>:<serviceaccount-name>. The Azure AD application must have "Storage Blob Data Contributor" permissions on the target storage account reference.
If the cluster fails to start, double-check:
- The ServiceAccount generated by CNPG is correctly annotated and matches the federated credential in Azure AD.
- The Azure AD application registration has the required permissions on the storage account.
- The destinationPath is in the correct format:
https://<account-name>.blob.core.windows.net/<container>.
There are no documented plugin-barman-cloud issues specific to cluster startup failures with Workload Identity, but namespace scoping can affect plugin operation—make sure the operator, plugin, and cluster are in compatible namespaces if you see startup issues reference.
Let me know if you need more details on the ServiceAccount or Azure AD setup!
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Hi @beingvishalt! I'm Dosu and I’m helping the plugin-barman-cloud team.
Yes, Azure AD Workload Identity authentication is supported by the Barman Cloud plugin v0.5.0 for backups to Azure Blob Storage. Your configuration using
azureCredentials: inheritFromAzureAD: trueis correct for enabling this feature reference.To make this work, you need to ensure that Azure AD Workload Identity is properly configured in AKS and Kubernetes. This means the pod's ServiceAccount must be annotated with the Azure AD application client ID, and the federated credentials in Azure AD must link to the ServiceAccount using the subject identifier format
system:serviceaccount:<namespace>:<serviceaccount-name>. The Azure AD application must have "Storage Blob Data Contributor" permissions on the target storage account reference.If the cluster fails to start, double-check:
- The ServiceAccount generated by CNPG is correctly annotated and matches the federated credential in Azure AD.
- The Azure AD application registration has the required permissions on the storage account.
- The destinationPath is in the correct format:
https://<account-name>.blob.core.windows.net/<container>.There are no documented plugin-barman-cloud issues specific to cluster startup failures with Workload Identity, but namespace scoping can affect plugin operation—make sure the operator, plugin, and cluster are in compatible namespaces if you see startup issues reference.
Let me know if you need more details on the ServiceAccount or Azure AD setup!
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
![]()
![]()
@dosu, do we need to have cluster as well as plugin and cnpg in same namespace? currently in my case I installed CNPG operator and Barman plugin in cnpg-system namespace, and I created Object store in test-namespace and also creating database cluster in the same namespace.
You do not need to have the CNPG operator and Barman plugin in the same namespace as your database cluster and ObjectStore. The official docs recommend installing the operator and plugin together (typically in cnpg-system), while clusters and ObjectStores can be in other namespaces like test-namespace—this is a supported and common setup as long as network policies and RBAC allow the operator to manage resources across namespaces docs docs.
However, all ServiceAccounts, secrets, and ObjectStore resources referenced by your cluster must exist in the same namespace as the cluster. Cross-namespace references are not supported: you need to duplicate ObjectStore and secret definitions in each namespace where you run a cluster, even if the configuration is the same issue #448 issue #524.
For Azure AD Workload Identity, make sure the ServiceAccount in the cluster's namespace is annotated with the correct Azure client ID, and that Azure AD federated credentials target that ServiceAccount (including the namespace in the subject). If you see startup or reconciliation issues, double-check that all referenced resources are present and correctly annotated in the cluster's namespace, and that RBAC allows the operator to access them.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
To make this work, you need to ensure that Azure AD Workload Identity is properly configured in AKS and Kubernetes. This means the pod's ServiceAccount must be annotated with the Azure AD application client ID, and the federated credentials in Azure AD must link to the ServiceAccount using the subject identifier format
system:serviceaccount:<namespace>:<serviceaccount-name>. The Azure AD application must have "Storage Blob Data Contributor" permissions on the target storage account
@dosu, My pod is successfully created with above configuration , but while taking backup i am getting error when I use Azure AD Workload Identity.
Errorrpc error: code = Unknown desc = exit status 2
but when i use Azure credentials instead of Azure AD Workload Identity it worked. then why with Azure AD Workload Identity it don't work.
I need more clarification on this, which pod's service account must be annotated with Azure AD application client ID, do you mean database pod that we are creating using CNPG or Barman Cloud pod or Cloudnative pg pod?
The ServiceAccount that must be annotated with the Azure AD application client ID is the one used by your PostgreSQL cluster pods—the database pods created by CNPG—not the operator or Barman Cloud plugin pods. This is because backup operations (including the Barman Cloud sidecar) run inside the database pods and authenticate to Azure Blob Storage using their identity docs discussion plugin docs.
If backups work with Azure credentials but fail with Azure AD Workload Identity, it usually means there’s a misconfiguration in one of these areas: the ServiceAccount annotation, the Azure AD federated credential (subject must match system:serviceaccount:<namespace>:<serviceaccount-name>), or the Azure AD application’s permissions (must have "Storage Blob Data Contributor" on the storage account) discussion.
Here’s a quick checklist:
- Make sure your cluster spec uses
serviceAccountTemplate.metadata.annotationsto set the Azure client ID. - Confirm the ServiceAccount name and namespace match the federated credential subject in Azure AD.
- Verify the Azure AD app has "Storage Blob Data Contributor" on the storage account.
- All referenced resources (ServiceAccount, ObjectStore) must be in the same namespace as the cluster.
- If you still see
rpc error: code = Unknown desc = exit status 2, check the logs in the database pod (especially the Barman Cloud sidecar) for more details.
Let me know if you want help reviewing your ServiceAccount or Azure AD setup!
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
The ServiceAccount that must be annotated with the Azure AD application client ID is the one used by your PostgreSQL cluster pods—the database pods created by CNPG—not the operator or Barman Cloud plugin pods. This is because backup operations (including the Barman Cloud sidecar) run inside the database pods and authenticate to Azure Blob Storage using their identity docs discussion plugin docs.
If backups work with Azure credentials but fail with Azure AD Workload Identity, it usually means there’s a misconfiguration in one of these areas: the ServiceAccount annotation, the Azure AD federated credential (subject must match
system:serviceaccount:<namespace>:<serviceaccount-name>), or the Azure AD application’s permissions (must have "Storage Blob Data Contributor" on the storage account) discussion.Here’s a quick checklist:
- Make sure your cluster spec uses
serviceAccountTemplate.metadata.annotationsto set the Azure client ID.- Confirm the ServiceAccount name and namespace match the federated credential subject in Azure AD.
- Verify the Azure AD app has "Storage Blob Data Contributor" on the storage account.
- All referenced resources (ServiceAccount, ObjectStore) must be in the same namespace as the cluster.
- If you still see
rpc error: code = Unknown desc = exit status 2, check the logs in the database pod (especially the Barman Cloud sidecar) for more details.Let me know if you want help reviewing your ServiceAccount or Azure AD setup!
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
![]()
![]()
@dosu, Can we use existing service account for each pod, because I am creating multiple DB clusters. So when we are going to use Azure Workload Identity we need to configure that service account name in azure portal blob storage. so Configuring each service account in azure portal is not possible so want to use existing account for all cluster. Either I want to use existing service account for all db cluster or if CNPG can stops creating Service account that will be good so I will apply patch later to cluster to use existing account
In CNPG v1.26, you cannot reuse a single existing ServiceAccount across multiple clusters. The operator always creates and manages a ServiceAccount named after each cluster, and the only customization available is adding annotations/labels via serviceAccountTemplate—not changing the name or disabling creation. This means you must configure Azure AD Workload Identity and grant permissions for each cluster's ServiceAccount separately, which can be tedious for many clusters (source).
A solution is coming: an upcoming feature (see PR #9287) will add a serviceAccountName field to the Cluster spec. This will let you reference a shared, pre-created ServiceAccount (with the right Azure annotations) across multiple clusters. serviceAccountName and serviceAccountTemplate are mutually exclusive—if you set serviceAccountName, CNPG will not create or manage a per-cluster ServiceAccount, and you can centralize your Azure AD configuration (source).
Until that feature is released, there’s no supported way to stop CNPG from creating a ServiceAccount per cluster or to patch the cluster to use an existing one. For now, you’ll need to grant Azure permissions to each cluster’s ServiceAccount individually.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.