implementing-rbac-for-kubernetes-cluster
Configure Kubernetes Role-Based Access Control (RBAC) to enforce least-privilege access to cluster resources. This skill covers Role/ClusterRole design, RoleBinding configuration, service account secu
What this skill does
# Implementing RBAC for Kubernetes Cluster ## Overview Configure Kubernetes Role-Based Access Control (RBAC) to enforce least-privilege access to cluster resources. This skill covers Role/ClusterRole design, RoleBinding configuration, service account security, namespace isolation, and audit logging for multi-tenant Kubernetes environments. ## Objectives - Design RBAC role hierarchy for multi-tenant clusters - Create granular Roles and ClusterRoles for different personas - Configure RoleBindings and ClusterRoleBindings with least privilege - Secure service accounts and limit their default permissions - Integrate RBAC with external identity providers (OIDC) - Audit and monitor RBAC usage with Kubernetes audit logs ## Key Concepts ### RBAC API Objects 1. **Role**: Namespace-scoped permissions (pods, services, deployments within a namespace) 2. **ClusterRole**: Cluster-wide permissions (nodes, namespaces, PVs, CRDs) 3. **RoleBinding**: Grants Role to users/groups/serviceAccounts in a namespace 4. **ClusterRoleBinding**: Grants ClusterRole cluster-wide ### Kubernetes RBAC Verbs - `get`, `list`, `watch`: Read-only operations - `create`, `update`, `patch`: Write operations - `delete`, `deletecollection`: Destructive operations - `impersonate`: Assume identity of another user - `escalate`: Modify RBAC roles (highly privileged) - `bind`: Create RoleBindings (highly privileged) ### Persona-Based Access Model - **Cluster Admin**: Full cluster management (limit to 2-3 people) - **Namespace Admin**: Full control within assigned namespace - **Developer**: Deploy and manage workloads in assigned namespace - **Viewer**: Read-only access to namespace resources - **CI/CD Service Account**: Deploy workloads, manage configmaps/secrets ## Implementation Steps ### Step 1: Disable Default Permissive Settings 1. Ensure `--authorization-mode=RBAC` is enabled on API server 2. Remove default cluster-admin bindings from non-admin users 3. Disable auto-mounting of service account tokens in pods 4. Restrict access to default service account in each namespace ### Step 2: Create Custom Roles ```yaml # Developer Role - namespace scoped apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: app-team name: developer rules: - apiGroups: ["", "apps", "batch"] resources: ["pods", "deployments", "services", "configmaps", "jobs"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [""] resources: ["secrets"] verbs: ["get", "list"] # read secrets but limit create/update - apiGroups: [""] resources: ["pods/log", "pods/exec"] verbs: ["get", "create"] ``` ### Step 3: Bind Roles to Users/Groups ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: developer-binding namespace: app-team subjects: - kind: Group name: "dev-team" apiGroup: rbac.authorization.k8s.io roleRef: kind: Role name: developer apiGroup: rbac.authorization.k8s.io ``` ### Step 4: Secure Service Accounts - Create dedicated service accounts per application - Disable automountServiceAccountToken for pods that don't need API access - Use projected service account tokens with audience and expiry - Bind minimum required permissions to each service account ### Step 5: OIDC Integration 1. Configure API server with OIDC flags (issuer-url, client-id, username-claim, groups-claim) 2. Map OIDC groups to Kubernetes groups in RoleBindings 3. Use short-lived tokens from OIDC provider 4. Configure kubectl with OIDC authentication plugin ### Step 6: Audit and Monitoring - Enable Kubernetes audit logging (audit-policy.yaml) - Log all RBAC-related events (role creation, binding changes) - Alert on ClusterRoleBinding creation/modification - Monitor for privilege escalation attempts - Regular review of who has cluster-admin access ## Security Controls | Control | NIST 800-53 | Description | |---------|-------------|-------------| | Access Control | AC-3 | RBAC enforcement | | Least Privilege | AC-6 | Minimum necessary Kubernetes permissions | | Account Management | AC-2 | Service account lifecycle | | Audit | AU-3 | Kubernetes audit logging | | Separation of Duties | AC-5 | Namespace isolation | ## Common Pitfalls - Granting cluster-admin to CI/CD pipelines - Using wildcard (*) verbs or resources in ClusterRoles - Not restricting pods/exec which allows container shell access - Leaving default service account with broad permissions - Not auditing who can create RoleBindings (privilege escalation vector) ## Verification - [ ] All users authenticate via OIDC (no static tokens/certs) - [ ] No unnecessary ClusterRoleBindings to cluster-admin - [ ] Developers limited to their assigned namespaces - [ ] Service accounts use least-privilege roles - [ ] automountServiceAccountToken disabled by default - [ ] Audit logging captures RBAC changes - [ ] `kubectl auth can-i` validates expected permissions per persona
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.