Kubernetes Unable to get services in namespace logs system serviceaccount default default

0 votes
Forbidden!Configured service account doesn't have access. Service account may have been revoked. User "system:serviceaccount:default:default" cannot get services in the namespace "mycomp-services-process"

I created a new namespace called "mycomp-service-process" and checked the issue but again it shows a message like this:

Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. User "system:serviceaccount:mycomp-services-process:default" cannot get services in the namespace "mycomp-services-process"
Oct 27, 2018 in Kubernetes by Damon Salvatore
• 5,980 points
7,519 views

1 answer to this question.

+1 vote

Your approach is wrong here. Namespace is not the issue. Here the first error is that of the srviceaccount in the default namespace is unable to get the services. You should assign a role to that user using clusterrolebinding.

Using min. privileges, create a role to access and list services:

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: default
  name: service-reader
rules:
- apiGroups: [""] # "" indicates the core API group
  resources: ["services"]
  verbs: ["get", "watch", "list"]

This will create a clusterrole which can list, get and watch services. Now you can use this clusterrole to create a clusterrolebinding:

kubectl create clusterrolebinding service-reader-pod \
  --clusterrole=service-reader  \
  --serviceaccount=default:default

Here the service-reader-pod is the name of clusterrolebinding and it assigns the service-reader clusterrole to the default serviceaccount in default namespace. Follow similar steps to rectify your second error.

In this case I created clusterrole and clusterrolebinding but you might want to create a roleand rolebinding instead. You can check the documentation in detail here

answered Oct 27, 2018 by ajs3033
• 7,300 points

Related Questions In Kubernetes

0 votes
1 answer

unable to start Kubernetes due to so many open files in system

You can try the following steps: You can ...READ MORE

answered May 1, 2018 in Kubernetes by shubham
• 7,340 points
2,079 views
0 votes
1 answer

How to change default Namespace in Kubernetes?

Hi@akhtar, Kubernetes will automatically create one namespace named ...READ MORE

answered Jul 5, 2020 in Kubernetes by MD
• 95,460 points
9,506 views
0 votes
1 answer

Unable to get cgroup stats for docker and kubelet services

Try and start kubelet with the following ...READ MORE

answered Sep 3, 2018 in Kubernetes by DareDev
• 6,890 points
5,103 views
0 votes
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
15,455 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,024 views
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,300 points
2,463 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP