Search code examples
kuberneteskubectl

'kubectl get namespace' command "namespaces is forbidden" error


When I am using kubectl get namespace command in my Kubernetes master node, I am getting proper output. And also I configured kubectl in my local machine. When I am running the same command from local machine configured with kubectl, I am getting error like the following,

Error from server (Forbidden): namespaces is forbidden: User "system:node:mildevkub020" cannot list resource "namespaces" in API group "" at the cluster scope

I copied the configuration file kubelet.conf from cluster and copied into .kube/config. And also installed the kubectl. This is the process what did till now.

Result of kubectl config view is like the following,

enter image description here

How can I resolve this issue?


Solution

  • Kubespray by default saves cluster admin kubeconfig file as inventory/mycluster/artifacts/admin.conf. Read more here: https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#accessing-kubernetes-api