AKS icon indicating copy to clipboard operation
AKS copied to clipboard

[BUG] Application Network (AppNet) member join fails on AKS Automatic: Flux helm-controller blocked by aks-managed-protect-system-namespaces

Open anthony-somerset-cko opened this issue 1 month ago • 3 comments

Describe the bug

Joining an AKS Automatic cluster to an Azure Kubernetes Application Network (AppNet, Microsoft.AppLink) as a member always fails. The member goes to Failed after about an hour:

"error": {
  "code": "CustomError",
  "message": "Resource provisioning timed out. Please retry; contact support if the failure persists."
}

The Kubernetes audit log shows the cause. AppNet's remote Flux helm-controller runs as the AppNet resource's system-assigned identity and tries to store its Helm release secret for the first chart (applink-system-ns) in kube-system. RBAC allows the request, because AppNet creates applink-flux-clusterrolebinding to cluster-admin for that identity. The AKS-managed ValidatingAdmissionPolicy aks-managed-protect-system-namespaces then denies it:

secrets "sh.helm.release.v1.applink-system-ns.v1" is forbidden: ValidatingAdmissionPolicy 'aks-managed-protect-system-namespaces' with binding 'aks-managed-protect-system-namespaces-binding' denied request: Modification of resources in managed system namespaces is not allowed

The applink-system namespace is never created. AppNet's remote istiod connects and creates its GatewayClasses (istio, istio-east-west, istio-remote, istio-waypoint), then fails on every write to applink-system until the join times out. No Istio CRDs, ztunnel or istio-cni are ever installed.

The policy exempts AKS system identities, certain kube-system service accounts and aks:trustedaccess:* users. The AppNet identity authenticates as a plain Entra user, so none of those exemptions match. This looks like the same class of problem as #5645 (microsoft.flux extension) and #5726 (microsoft.dapr extension).

We can reproduce it both with the az CLI and with OpenTofu using azapi. The result is the same either way.

To Reproduce

Prerequisites: providers Microsoft.ContainerService and Microsoft.AppLink registered, and features Microsoft.AppLink/PublicPreview and Microsoft.ContainerService/AKS-AutomaticHostedSystemProfilePreview registered.

Option A, az CLI:

az appnet create -g <rg> --appnet-name <appnet> -l swedencentral --identity-type SystemAssigned

az aks create -g <rg> -n <cluster> -l swedencentral \
  --sku automatic --enable-hosted-system --enable-gateway-api

# Automatic enables App Routing Istio by default, which can't coexist with AppNet's Istio
az aks approuting gateway istio disable -g <rg> -n <cluster> --yes

az appnet member join -g <rg> --appnet-name <appnet> --member-name <cluster> \
  --member-resource-id $(az aks show -g <rg> -n <cluster> --query id -o tsv) \
  --upgrade-mode FullyManaged --release-channel Stable --east-west-gateway Internal

Option B, OpenTofu with azapi. The cluster is a Microsoft.ContainerService/managedClusters@2026-07-01 azapi_resource with sku = { name = "Automatic", tier = "Standard" }, a BYO VNet hostedSystemProfile, ingressProfile.gatewayAPI.installation = "Standard" and ingressProfile.webAppRouting.gatewayApiImplementations.appRoutingIstio.mode = "Disabled" from the first PUT, and no serviceMeshProfile. AppNet and the member:

resource "azapi_resource" "appnet" {
  type                      = "Microsoft.AppLink/appLinks@2026-08-01-preview"
  name                      = "<appnet>"
  parent_id                 = "<resource group id>"
  location                  = "swedencentral"
  schema_validation_enabled = false
  identity { type = "SystemAssigned" }
  body = {}
}

resource "azapi_resource" "appnet_member" {
  type                      = "Microsoft.AppLink/appLinks/appLinkMembers@2026-08-01-preview"
  name                      = "<cluster>"
  parent_id                 = azapi_resource.appnet.id
  location                  = "swedencentral"
  schema_validation_enabled = false
  body = {
    properties = {
      clusterType = "AKS"
      metadata    = { resourceId = "<cluster resource id>" }
      upgradeProfile = {
        mode                       = "FullyManaged"
        fullyManagedUpgradeProfile = { releaseChannel = "Stable" }
      }
      connectivityProfile = { eastWestGateway = { visibility = "Internal" } }
    }
  }
  timeouts { create = "90m" }
}

Then:

  1. Wait about 60 minutes. The member ends in Failed with the CustomError above.
  2. Enable the kube-audit diagnostic setting on the cluster and query AKSAudit for the AppNet identity's object ID (the subject of applink-flux-clusterrolebinding).

Relevant logs

Identifiers are replaced with <...> placeholders.

Cluster state after the failed join:

$ kubectl get clusterrolebinding -o name | grep applink
clusterrolebinding.rbac.authorization.k8s.io/applink-flux-clusterrolebinding     # -> cluster-admin, User <appnet-identity-object-id>
clusterrolebinding.rbac.authorization.k8s.io/applink-istiod-clusterrolebinding   # -> applink-istiod-clusterrole, User <appnet-identity-object-id>

$ kubectl get ns applink-system
Error from server (NotFound): namespaces "applink-system" not found

$ kubectl get crd | grep -c istio
0

$ kubectl get gatewayclass
NAME              CONTROLLER                     ACCEPTED   AGE
istio             istio.io/gateway-controller    Unknown    62m
istio-east-west   istio.io/eastwest-controller   Unknown    62m
istio-remote      istio.io/unmanaged-gateway     Unknown    62m
istio-waypoint    istio.io/mesh-controller       Unknown    62m

The AKS-side managedClusters/meshMemberships/default shows provisioningState: Succeeded.

AKSAudit requests from the AppNet identity. fluxcd-helm-controller retries about every 5 minutes and is denied every time:

TimeGenerated (UTC)        UserAgent               Verb    Code  RequestUri
2026-10-30T09:40:19.0333Z  fluxcd-helm-controller  list    200   /api/v1/namespaces/kube-system/secrets?labelSelector=name=applink-system-ns,owner=helm
2026-10-30T09:40:19.0957Z  fluxcd-helm-controller  get     200   /apis/apiextensions.k8s.io/v1
2026-10-30T09:40:19.1130Z  fluxcd-helm-controller  get     200   /apis/apiextensions.k8s.io/v1/customresourcedefinitions/gateways.gateway.networking.k8s.io
2026-10-30T09:40:19.1221Z  fluxcd-helm-controller  get     200   /openapi/v3
2026-10-30T09:40:19.1599Z  fluxcd-helm-controller  get     200   /openapi/v3/api/v1
2026-10-30T09:40:19.2901Z  fluxcd-helm-controller  create  403   /api/v1/namespaces/kube-system/secrets
...
2026-10-30T09:45:04.7808Z  fluxcd-helm-controller  create  403   /api/v1/namespaces/kube-system/secrets

The denied request's audit annotations, with the object ID replaced:

{
  "objectRef": { "resource": "secrets", "namespace": "kube-system", "name": "sh.helm.release.v1.applink-system-ns.v1" },
  "responseStatus": {
    "code": 403,
    "reason": "Forbidden",
    "message": "secrets \"sh.helm.release.v1.applink-system-ns.v1\" is forbidden: ValidatingAdmissionPolicy 'aks-managed-protect-system-namespaces' with binding 'aks-managed-protect-system-namespaces-binding' denied request: Modification of resources in managed system namespaces is not allowed"
  },
  "annotations": {
    "authorization.k8s.io/decision": "allow",
    "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"applink-flux-clusterrolebinding\" of ClusterRole \"cluster-admin\" to User \"<appnet-identity-object-id>\"",
    "validation.policy.admission.k8s.io/validation_failure": "[{\"message\":\"Modification of resources in managed system namespaces is not allowed\",\"policy\":\"aks-managed-protect-system-namespaces\",\"binding\":\"aks-managed-protect-system-namespaces-binding\",\"expressionIndex\":0,\"validationActions\":[\"Deny\",\"Audit\"]}]"
  }
}

Because the namespace is missing, AppNet's remote istiod (pilot-discovery/1.30.5-aks and pilot-discovery/1.31.1-aks, same identity) gets 404s in a loop. That's about 1,300 requests in 5 minutes:

Verb    Resource    Namespace       Code  Count (5 min)
create  leases      applink-system  404   239
get     leases      applink-system  404   241
create  configmaps  applink-system  404   231
get     configmaps  applink-system  404   232
message: namespaces "applink-system" not found

Gatekeeper (running with --log-denies) logged no denials, and no other admission or RBAC errors appear for the AppNet identity.

Expected behavior

The member join succeeds on AKS Automatic. Either AppNet authenticates through Trusted Access (an aks:trustedaccess:* identity, which the policy already exempts) or stores its Helm release state outside the managed system namespaces, or aks-managed-protect-system-namespaces exempts the AppNet control plane.

The Application Network docs list the AppNet join requirements (no Istio add-on, Entra integration, OIDC issuer, managed Gateway API) but don't say AKS Automatic is unsupported. This cluster meets all four.

Environment (please complete the following information):

  • CLI Version: azure-cli 2.90.0
  • Kubernetes version: 1.36.5 (AKS Automatic, hosted system profile, Azure Linux 3.0 nodes)
  • CLI Extension version: aks-preview 22.0.0b15, appnet-preview 1.0.0b4
  • OpenTofu 1.13.2, azapi provider 2.13.0
  • Region: swedencentral
  • AppNet API version: 2026-08-01-preview, member FullyManaged / Stable channel

Additional context

  • Fails the same way every time: the original join failed, a full remove-and-rejoin is hitting the same 403 on every retry, and a colleague sees the same error on a separate cluster.
  • The AKS-side managedClusters/meshMemberships/default reports Succeeded, so the failure only shows up as the generic AppNet timeout. A clearer error at join time, such as AppNet checking the cluster SKU or the policy up front, would have saved a lot of debugging.
  • Happy to share subscription, cluster and operation IDs privately through a support case if that helps.

anthony-somerset-cko avatar Oct 30 '26 09:10 anthony-somerset-cko

looking into this one. circle back soon

jack4it avatar Nov 01 '26 20:11 jack4it

Thank you for reporting the issue! We have a fix for this already. However, due to the year-end code freeze, the rollout of the fix will be delayed. In the meanwhile, please try to join AppNet with regular AKS clusters.

Winbobob avatar Nov 02 '26 19:11 Winbobob

5. Thank you for reporting the issue! We have a fix for this already. However, due to the year-end code freeze, the rollout of the fix will be delayed. In the meanwhile, please try to join AppNet with regular AKS clusters.

Thanks but we only use AKS automatic today, whats the likely ETA on a fix rollout? any conversion/migration from AKS Automatic to AKS Standard is likely to take just as long as waiting by my guesses.

anthony-somerset-cko avatar Nov 03 '26 10:11 anthony-somerset-cko