Kubernetes version : v1.19.0
I have created a user and performed clusterrolebinding with a role cluster-admin.
[root@project1-master ~]# kubectl describe clusterrole cluster-admin
Name: cluster-admin
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
*.* [] [] [*]
[*] [] [*]
[root@project1-master ~]# kubectl describe clusterrolebinding sajeesh cluster-admin
Name: sajeesh
Labels: <none>
Annotations: <none>
Role:
Kind: ClusterRole
Name: cluster-admin
Subjects:
Kind Name Namespace
---- ---- ---------
User sajeesh
Name: cluster-admin
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
Role:
Kind: ClusterRole
Name: cluster-admin
Subjects:
Kind Name Namespace
---- ---- ---------
Group system:masters
I am able to run kubectl with this useraccount and get pods information :
[root@project1-master ~]# kubectl get pods --as sajeesh
NAME READY STATUS RESTARTS AGE
busyb 1/1 Running 3 21h
But when i try to access kube-apiserver using curl it show forbidden error as following :
[root@project1-master ~]# curl --cacert /etc/kubernetes/pki/ca.crt --cert sajeesh.crt --key sajeesh.key https://$IP:6443/api/v1/namespaces/default/pods/busyb
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "pods \"busyb\" is forbidden: User \"system:anonymous\" cannot get resource \"pods\" in API group \"\" in the namespace \"default\"",
"reason": "Forbidden",
"details": {
"name": "busyb",
"kind": "pods"
},
"code": 403
I have re-verified the cacert , cert & key i am providing with that user account .They are correct.
Any suggestions why this is happening and how to fix it.