⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 998+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Senior DevOps / SRE [L2] Kubernetes RBAC & Security Production Scenario [L2]

Q: You run a pod that needs to call the Kubernetes API (e.g., to list other pods). How do you set this up securely?

1. Create a ServiceAccount: kubectl create serviceaccount my-app -n my-namespace

#Kubernetes #RBAC & Security #L2 #Container Orchestration #K8s
🎙️ Candidate Opening & Architectural Context
""In our production Kubernetes clusters running microservices on EKS/AKS, this was a classic operational challenge. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix.""
Advertisement

🛠️ Production Runbook & Step-by-Step Resolution

1️⃣

Initial Diagnostics & Root Cause Analysis

The pod will then have a token mounted at /var/run/secrets/kubernetes.io/serviceaccount/token which it can use to authenticate to the API server.

  • Create a ServiceAccount: kubectl create serviceaccount my-app -n my-namespace
  • Create a Role with only the needed permissions (principle of least privilege):
  • Create a RoleBinding linking the ServiceAccount to the Role.
2️⃣

Remediation & Permanent Safeguards

Avoid using the default ServiceAccount — it often has more permissions than needed.

rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list"]
  • Set serviceAccountName: my-app in the pod spec.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Create a ServiceAccount: kubectl create serviceaccount my-app -n my-namespace."
⚡ 60-Second Elevator Pitch Talking Points
  • Create a ServiceAccount: kubectl create serviceaccount my-app -n my-namespace
  • Create a Role with only the needed permissions (principle of least privilege):
  • Create a RoleBinding linking the ServiceAccount to the Role.
Advertisement
Want more Kubernetes scenarios?
Explore our complete collection of scenario-based Kubernetes interview runbooks.
Browse All Kubernetes Questions →

📚 Related Production Scenarios in Kubernetes