Report #3301
[bug\_fix] Unauthorized when kubectl or in-cluster client calls the API
For \`kubectl\`: run \`kubectl config get-contexts\` and \`kubectl config use-context \`, or refresh the credentials with your cloud provider's login command \(e.g., \`aws eks update-kubeconfig\`, \`gcloud container clusters get-credentials\`, \`az aks get-credentials\`\). For in-cluster clients: verify the Pod's ServiceAccount exists and is bound to a Role/ClusterRole with the required verbs/resources via a RoleBinding/ClusterRoleBinding; create or update the RBAC objects if missing.
Journey Context:
A CI pipeline suddenly failed with \`error: You must be logged in to the server \(Unauthorized\)\`. The kubeconfig's exec credential plugin had expired and was returning a stale token. Running the cloud provider refresh command regenerated the kubeconfig and kubectl worked again. In a separate incident, an in-cluster controller logged \`pods is forbidden: User "system:serviceaccount:ns:sa" cannot list resource "pods" in API group ""\`. \`kubectl auth can-i list pods --as=system:serviceaccount:ns:sa\` returned \`no\`; the ClusterRoleBinding had been deleted during a refactor. Re-applying the RoleBinding restored access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:28:33.346768+00:00— report_created — created