Code error 403 when trying to access Kubernetes cluster

0 votes

I've created a kubernetes cluster and all the pods are in running state. But when I try to access the cluster I get a code error.

kubectl cluster info
Kubernetes master is running at https://x.x.x.x:6443
KubeDNS is running at https://x.x.x.x:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

"status": "Failure",
  "message": "namespaces is forbidden: User \"system:anonymous\" cannot list namespaces at the cluster scope",
  "reason": "Forbidden",
  "details": {
    "kind": "namespaces"
  },
  "code": 403   

All my pods seem to be working fine

kube-system   calico-etcd-6629s                                      1/1       Running   0          5h
kube-system   calico-kube-controllers-675684d4bb-5h28d               1/1       Running   0          5h
kube-system   calico-node-r75wv                                      2/2       Running   0          5h
kube-system   etcd-sp2013a....                                        1/1       Running   0          5h
kube-system   kube-apiserver-sp2013a ...                              1/1       Running   0          5h
kube-system   kube-controller-manager-sp2013a....                     1/1       Running   0          5h
kube-system   kube-dns-6f4....df-fcqvt                               3/3       Running   0          5h
kube-system   kube-proxy-mpf2j                                       1/1       Running   0          5h
kube-system   kube-scheduler-sp2013a......                            1/1       Running   0          5h
Jan 4 in Kubernetes by Ali
• 10,450 points
610 views

1 answer to this question.

0 votes

You get this error because you're getting blocked by RBAC policies. Basically, RBAC policies set to restrict the resources you use and limits a few of your action. 

There are two possibilities, either you haven't created an RBAC or it's somehow restricting the cluster access.

By default, your clusterrolebinding has system:anonymous set which blocks the cluster access.

Execute the following command, it will set a clusterrole as cluster-admin which will give you the required access.

kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous
answered Jan 4 by Kabeer

Related Questions In Kubernetes

0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
1,057 views
+3 votes
1 answer
0 votes
1 answer

Error in syncing pod - Kubernetes

You are getting this error because all you're ...READ MORE

answered Jan 4 in Kubernetes by Layla
42 views