Interview Prep/Python for DevOps/boto3, HTTP & API errors

`kubernetes.client.exceptions.ApiException: (403) Reason: Forbidden ... "pods is forbidden: User \"system:serviceaccount:ops:auditor\" cannot list resource \"pods\" in API group \"\" at the cluster scope"`

BeginnerTroubleshootingboto3, HTTP & API errors
Answer

Likely causes → The service account has no RBAC permission for that verb/resource/scope (a namespaced Role cannot grant cluster-scope list).

Diagnose →

kubectl auth can-i list pods --all-namespaces --as=system:serviceaccount:ops:auditor
kubectl get rolebinding,clusterrolebinding -A -o wide | grep auditor

Fix → Create a ClusterRole with get, list, watch on pods and a ClusterRoleBinding to the service account (or use namespaced calls with a Role per namespace).

Prevent → Ship RBAC manifests with the tool and test with kubectl auth can-i.

All Python for DevOps questions Roadmap: Python for automation

More on boto3, HTTP & API errors