AKS Namespace Won't Delete

Ho, Keith D 160 Reputation points
2025-01-16T21:40:22.6766667+00:00

Currently, I am trying to delete one of my namespaces, but it keeps getting automatically recreated.

This is the yaml file of the namespace and I have no idea why it keeps creating itself.

kind: Namespace
apiVersion: v1
metadata:
  name: app-routing-system
  uid: <--uid-->
  labels:
    kubernetes.io/metadata.name: app-routing-system
  managedFields:
    - manager: aks-app-routing-operator
      operation: Apply
      apiVersion: v1
      time: '2025-01-15T19:41:46Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:spec: {}
spec:
  finalizers:
    - kubernetes
status:
  phase: Active

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,237 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mounika Reddy Anumandla 1,955 Reputation points Microsoft Vendor
    2025-01-17T01:44:30.3233333+00:00

    Hi Ho, Keith D,

    Welcome to the Microsoft Q&A Platform. Thank you for posting your query here.

    From your Yaml file, I can see the AKS App Routing Operator (aks-app-routing-operator) is managing this namespace. It automatically recreates system namespaces required for app routing if they are missing. This is evident from the managedFields entry in your YAML, which lists aks-app-routing-operator as the manager.
    https://learn.microsoft.com/en-us/azure/aks/app-routing#remove-the-application-routing-add-on

    Check if AKS App Routing is enabled on your cluster:

    az aks show --resource-group <your-resource-group> --name <your-cluster-name> --query "addonProfiles.appRouting"
    

    To disable App Routing addon.

    https://learn.microsoft.com/en-us/cli/azure/aks/approuting?view=azure-cli-latest#az-aks-approuting-disable

    After disabling, delete the namespace:

    kubectl delete namespace app-routing-system
    

    You can remove the Namespace Finalizer (If Stuck in Terminating State)

    https://kubernetes.io/blog/2021/05/14/using-finalizers-to-control-deletion/#forcing-a-deletion-of-a-namespace

    Hope this helps!

    Let me know if you have any further queries!

    If the comment is helpful, please click "upvote" to let us know :-).

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.