How to fix this issue..?

gowtham@AIT 0 Reputation points
2025-02-27T21:14:24.4933333+00:00

I have been facing the following error on my Kubernets deployment.

Previously the deployment was successful with the default namespace but we are facing the below mentioned error on the deployment.

Error:

$ kubectl apply -f deploy.yaml

configmap/intime-test-config unchanged

deployment.apps/intime-test-app created

Error from server (Forbidden): error when creating "deploy.yaml": admission webhook "validation.gatekeeper.sh" denied the request: [azurepolicy-k8sazurev1blockdefault-69441b94455ae7313640] Usage of the default namespace is not allowed, name: intime-test-service, kind: Service

Is there any solution to fix this issue..?

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,292 questions
{count} votes

1 answer

Sort by: Most helpful
  1. hossein jalilian 9,940 Reputation points
    2025-02-27T21:38:02.51+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    The error you're encountering is due to a policy that restricts the creation of resources in the default namespace of your Azure Kubernetes Service (AKS) cluster. This is a common security practice to ensure better organization and isolation of resources. To resolve this issue, you need to:

    • Specify a non-default namespace in your deployment YAML file.
    • Create the namespace if it doesn't already exist.

    If you want to set a default namespace for your current context to avoid specifying it in every command, use:

    kubectl config set-context --current --namespace=your-namespace-name
    

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    0 comments No comments

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.