Kubernetesexit code > 0

Error from server (Forbidden): user cannot list resource

$Error from server (Forbidden): pods is forbidden: User "dev-user" cannot list resource "pods" in API group "" in the namespace "default"

Analysis

Your Kubernetes user or service account does not have the RBAC permissions to perform the requested action.

Common Triggers

  • Missing Role or ClusterRole.
  • Missing RoleBinding or ClusterRoleBinding.
  • Trying to access a resource in a different namespace.

Debug Checks

  • $Check permissions: kubectl auth can-i list pods --as <user>.

Resolution

1
Create a Role and RoleBinding to grant permissions.
2
Ask the cluster admin for access.