kubernetes auth_error ai_generated true

Error creating: pods is forbidden: error looking up service account: serviceaccount not found

ID: kubernetes/k8s-service-account-not-found

Also available as: JSON · Markdown
92%Fix Rate
90%Confidence
55Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

Pod references a ServiceAccount that doesn't exist in the namespace. Pods can't be created until the ServiceAccount is created.

generic

Workarounds

  1. 95% success Create the missing ServiceAccount in the correct namespace
    kubectl create serviceaccount <name> -n <namespace>

    Sources: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

  2. 88% success Verify the pod spec references the correct ServiceAccount name and namespace
    kubectl get serviceaccounts -n <namespace> to list available service accounts

    Sources: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

Dead Ends

Common approaches that don't work:

  1. Remove the serviceAccountName field to use default 65% fail

    May break RBAC-dependent workloads that need specific permissions

  2. Create the ServiceAccount in a different namespace 90% fail

    ServiceAccounts are namespace-scoped — must be in the same namespace as the pod

Error Chain

Leads to:
Preceded by:
Frequently confused with: