Interview Prep/Monitoring & Observability/Kubernetes monitoring and the Prometheus Operator

Prometheus pod logs `forbidden: User "system:serviceaccount:monitoring:prometheus-k8s" cannot list resource "endpoints" in API group "" in the namespace "shop"`

IntermediateTroubleshootingKubernetes monitoring and the Prometheus Operator
Answer

Likely causes → The Operator namespaced RBAC doesn't include the new namespace (kube-prometheus creates Roles per listed namespace).

Diagnose →

kubectl auth can-i list endpoints -n shop --as=system:serviceaccount:monitoring:prometheus-k8s

Fix → Add a Role/RoleBinding in shop, or use a ClusterRole for cluster-wide discovery.

Prevent → Include the monitoring Role in namespace onboarding.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Kubernetes monitoring and the Prometheus Operator