[BUG] ArgoCD AKS extension deployment fails with Helm upgrade error due to immutable `spec.selector` field conflicts on existing Deployments and StatefulSets.
Describe the bug
ArgoCD AKS extension deployment fails with Helm upgrade error due to immutable spec.selector field conflicts on existing Deployments and StatefulSets. The extension cannot patch existing ArgoCD resources because Kubernetes prevents modification of selector labels on already-deployed workloads.
To Reproduce Steps to reproduce the behavior:
- Deploy ArgoCD extension to an AKS cluster that already has ArgoCD resources deployed
- Run Bicep deployment with
Microsoft.KubernetesConfiguration/extensions@2024-11-01resource type for ArgoCD extension - Observe Helm upgrade failure with selector immutability errors
Expected behavior The ArgoCD extension should successfully upgrade or provide a clear migration path for existing ArgoCD installations. Alternatively, the extension should detect conflicting resources and provide actionable error messaging to clean up before deployment.
Error Details
Helm Upgrade Failed : Unable to create/update Kubernetes resources for the extension : Recommendation Please check that there are no policies blocking the resource creation/update for the extension : InnerError [an error occurred while rolling back the release. original upgrade error: cannot patch "argocd-applicationset-controller" with kind Deployment: Deployment.apps "argocd-applicationset-controller" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-applicationset-controller"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-notifications-controller" with kind Deployment: Deployment.apps "argocd-notifications-controller" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-notifications-controller"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-repo-server" with kind Deployment: Deployment.apps "argocd-repo-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-repo-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-server" with kind Deployment: Deployment.apps "argocd-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-dex-server" with kind Deployment: Deployment.apps "argocd-dex-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-dex-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-application-controller" with kind StatefulSet: StatefulSet.apps "argocd-application-controller" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'revisionHistoryLimit', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden: cannot patch "argocd-applicationset-controller" with kind Deployment: Deployment.apps "argocd-applicationset-controller" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-applicationset-controller"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-notifications-controller" with kind Deployment: Deployment.apps "argocd-notifications-controller" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-notifications-controller"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-repo-server" with kind Deployment: Deployment.apps "argocd-repo-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-repo-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-server" with kind Deployment: Deployment.apps "argocd-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-dex-server" with kind Deployment: Deployment.apps "argocd-dex-server" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"argocd", "app.kubernetes.io/name":"argocd-dex-server"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "argocd-application-controller" with kind StatefulSet: StatefulSet.apps "argocd-application-controller" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'revisionHistoryLimit', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden] . For general troubleshooting visit: https://aka.ms/k8s-extensions-TSG . For more application specific troubleshooting visit: https://aka.ms/gitops-flux-v2-troubleshooting
**Bicep template **
param clusterName string
param workloadIdentityClientId string
param ssoWorkloadIdentityClientId string
param url string = 'https://argocd.tembi.io'
@description('Agent pool name to deploy ArgoCD components to')
param agentPoolName string = 'npgeneric'
@description('ArgoCD hostname without environment prefix')
param baseHostname string = 'argocd.tembi.io'
@description('Environment name for hostname prefix (dev, prod, etc.)')
param environment string
// Construct the full hostname based on environment
var hostname = environment == 'prod' ? baseHostname : '${environment}-${baseHostname}'
@description('OIDC configuration for ArgoCD SSO')
param oidcConfig string
var defaultPolicy = 'role:readonly'
var policy = '''
p, role:org-admin, applications, *, */*, allow
p, role:org-admin, clusters, get, *, allow
p, role:org-admin, repositories, get, *, allow
p, role:org-admin, repositories, create, *, allow
p, role:org-admin, repositories, update, *, allow
p, role:org-admin, repositories, delete, *, allow
g, 07ef10e1-201b-4152-876d-8a8421c907b0, role:org-admin
'''
resource cluster 'Microsoft.ContainerService/managedClusters@2025-05-01' existing = {
name: clusterName
}
resource extension 'Microsoft.KubernetesConfiguration/extensions@2024-11-01' = {
name: 'argocd'
scope: cluster
properties: {
extensionType: 'Microsoft.ArgoCD'
releaseTrain: 'preview'
configurationSettings: {
deployWithHighAvailability: 'false'
'workloadIdentity.enable': 'true'
'workloadIdentity.clientId': workloadIdentityClientId
'workloadIdentity.entraSSOClientId': ssoWorkloadIdentityClientId
'config-maps.argocd-cm.data.oidc\\.config': oidcConfig
'config-maps.argocd-cm.data.url': url
'config-maps.argocd-rbac-cm.data.policy\\.default': defaultPolicy
'config-maps.argocd-rbac-cm.data.policy\\.csv': policy
'config-maps.argocd-cmd-params-cm.data.application\\.namespaces': 'default, argocd'
'common.nodeSelector.agentpool': agentPoolName
'config-maps.argocd-cmd-params-cm.data.server\\.insecure': 'true' // needs to be set to true in order to work with cert-manager. Generated certs
}
}
}
I just deleted the extension and redeployed it with success (sort of). Now i dont see the config-map being deployed.
@ponatara can you please help?
Looking into this.
@nbwdk What is the version of the extension you get getting this issue?
@nbwdk What is the version of the extension you get getting this issue?
Kubernetes version is: 1.33.6 Extension version: 1.0.0-preview
@nbwdk how is the previous argocd installed? is it installed using OSS helm chart?
Regarding the configmaps the configuration settings changed with version 1.0.0-preview. Please refer the latest documentation https://learn.microsoft.com/en-us/azure/azure-arc/kubernetes/tutorial-use-gitops-argocd
Also extension has adopted the OSS helm chart with some minor tweaks, in case you are using OSS helm chart to install argocd, extension install should seamlessly take over.
All installations of the argocd extension is done through Bicep, as posted.
I can see that the configurationSettings has changed, i will change this is our source-code, and retry.
@nbwdk let us know if we can close the issue
This issue will now be closed because it hasn't had any activity for 7 days after stale. @nbwdk feel free to comment again on the next 7 days to reopen or open a new issue after that time if you still have a question/issue or suggestion.