Kubernetes log, User systemserviceaccountdefaultdefault cannot get services in the namespace
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The log message saying system:serviceaccount:default:default cannot get services means the pod identity lacks read permission in the target namespace. This usually appears when a workload relies on service discovery, but the default service account has not been granted explicit rights. The fix is not in application code, it is in Kubernetes RBAC policy.
Why This Permission Error Appears
Kubernetes authenticates the request as a service account and then authorizes it through Role Based Access Control rules. If no matching rule allows the get verb on the services resource in the namespace, the API server denies the request. The default service account is intentionally limited, so this is expected behavior in secure clusters.
A common source of confusion is namespace scope. A Role is namespaced and only grants permissions inside one namespace. A ClusterRole can span the cluster, but it is broader and should be used carefully. For this case, a namespace local Role and RoleBinding are usually enough.
You can confirm the effective permission with an impersonation check. This avoids guesswork and tells you exactly what the API server sees.
If the command prints no, RBAC is the direct cause. If it prints yes, look for a different issue such as wrong namespace, network policy, or a malformed client request.
Implement A Least Privilege RBAC Fix
Create a dedicated service account for the workload instead of expanding rights for the namespace default account. Then bind only the verbs and resources the workload needs.
Update the pod or deployment to use service-reader.
Apply the manifests and validate again with kubectl auth can-i. This pattern keeps permissions explicit, reviewable, and easy to audit.
Troubleshooting Workflow In Production
When the error appears in logs, follow a short sequence.
- Identify the exact identity in the error message.
- Verify the namespace where the API call is made.
- Run
kubectl auth can-ifor that identity and verb. - Inspect current bindings with
kubectl get rolebinding -n default. - Apply the minimal Role and RoleBinding.
This workflow prevents over granting permissions under pressure. It also helps teams document why each permission exists, which is important during security reviews.
Verification And Hardening Steps
After the fix, verify from inside the running pod, not only from an admin workstation. Execute a simple API read with the pod identity and confirm expected access while unrelated resources stay denied. This validates both authentication token mounting and effective RBAC policy.
You can also automate this check in deployment pipelines. For example, run kubectl auth can-i for a small matrix of required verbs and resources before promoting manifests. If a permission is missing, fail fast with a clear message. If a permission is broader than intended, flag it for review.
Finally, document ownership for each Role and RoleBinding. Teams often inherit old permissions that no longer map to active workloads. Regular cleanup keeps the namespace policy understandable and reduces accidental privilege growth over time.
Common Pitfalls
- Binding permissions to the
defaultservice account for convenience. This often leaks rights to unrelated pods. - Creating a
Rolein one namespace while the workload runs in another namespace. - Granting only
listbut notget, then seeing partial behavior. - Using
ClusterRoleBindingfor a namespace only need. - Assuming restart is optional after changing service account configuration on a deployment.
Summary
- The error is an RBAC authorization failure, not an application logic bug.
- Use
kubectl auth can-iwith impersonation to verify permissions quickly. - Prefer dedicated service accounts and least privilege namespace roles.
- Bind only required verbs for required resources.
- Keep a repeatable troubleshooting sequence for faster incident response.
Related reading
- Kubernetes logging level --v
- Kubernetes Logs - How to get logs for kube-system pods
- kubernetes lost /.kube/config
- Kubernetes microservices monitoring alerting
- Kubernetes mount volume on existing directory with files inside the container
- Kubernetes multiple ingress objects with same configs
- Kubernetes modify a secret using kubectl?
- Kubernetes MongoDB operator - Invalid featureCompatibilityVersion document in admin.system.version

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.