6

I am trying to use the K8S through Azure AKS.

But when doing a simple command like: kubectl create namespace airflow

I get the following error message:

Error from server (Forbidden): namespaces is forbidden: User "xxx" cannot create resource "namespaces" in API group "" at the cluster scope

I have already commanded az aks get-credentials to connect to the cluster and then I try to create the namespace but without success.

Jessica
  • 167
  • 2
Felipe FB
  • 1,212
  • 6
  • 22
  • 55

3 Answers3

10

In my case, this works when I use this command:

az aks get-credentials --resource-group <RESOURCE GROUP NAME> --name <AKS Cluster Name> --admin
Felipe FB
  • 1,212
  • 6
  • 22
  • 55
4

You dont have sufficient privileges to create namespace in the k8s cluster though you have access to the cluster

Check the below command to know if you have permission to create namespace

# kubectl auth can-i create namespace
yes
P Ekambaram
  • 15,499
  • 7
  • 34
  • 59
0

Make sure your /.kube/config has been configured with correct user name and credentials. Then run the following command to set the context:

Kubectl config set-context —user=xx yourclustername 
GeralexGR
  • 2,973
  • 6
  • 24
  • 33
Eben
  • 1