A pod uses a service account 'my-sa' with a RoleBinding that grants get and list on pods in namespace 'app'. The pod runs a process that calls the Kubernetes API to list pods. However, the API call returns 403. What is the most likely cause?
Trap 1: The API server is not running.
When the API server is unreachable, kubectl typically fails with a connection refused or timeout error rather than an HTTP 403 Forbidden. A 403 indicates the request reached the API server and was authenticated but authorization failed, which is a permissions issue, not an infrastructure outage. So this option is incorrect because the error type itself rules out a down API server.
Trap 2: The RoleBinding is in the wrong namespace.
A RoleBinding is namespaced and grants permissions only within its own namespace. The pod is running in the 'app' namespace, and the RoleBinding is also in 'app', so it correctly applies to that pod's service account. If it were in another namespace, it would have no effect, but that is not the case here, so this cannot be the cause of the 403.
Trap 3: The Role does not include list permission.
A Role grants specific verbs on specific resources; if the verb were missing, the API server would return 403 for that action. However, the role does include the list verb for the required resource, so the authorization check would pass. Since the error persists despite having list permission, this option does not explain the failure.
- A
The API server is not running.
Why it fails: When the API server is unreachable, kubectl typically fails with a connection refused or timeout error rather than an HTTP 403 Forbidden. A 403 indicates the request reached the API server and was authenticated but authorization failed, which is a permissions issue, not an infrastructure outage. So this option is incorrect because the error type itself rules out a down API server.
- B
The RoleBinding is in the wrong namespace.
Why it fails: A RoleBinding is namespaced and grants permissions only within its own namespace. The pod is running in the 'app' namespace, and the RoleBinding is also in 'app', so it correctly applies to that pod's service account. If it were in another namespace, it would have no effect, but that is not the case here, so this cannot be the cause of the 403.
- C
The pod does not have the service account token mounted.
For in-cluster clients, the Kubernetes client library reads the service account token from /var/run/secrets/kubernetes.io/serviceaccount/token. If automountServiceAccountToken is set to false on the Pod or ServiceAccount, that token file is absent, leaving the client with no credentials. Without a token, the API server cannot authenticate the request and returns 403 Forbidden, matching the symptom exactly.
- D
The Role does not include list permission.
Why it fails: A Role grants specific verbs on specific resources; if the verb were missing, the API server would return 403 for that action. However, the role does include the list verb for the required resource, so the authorization check would pass. Since the error persists despite having list permission, this option does not explain the failure.