Kubernetes API Security

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up kubernetes api security by defining strict roles and binding them to users. These rules check every request sent to the cluster control plane. Most teams start by granting broad roles so developers can fix broken apps fast. Over time, those wide roles stay in place and expose live workloads to mistakes. How kubernetes api security works with native roles The cluster control plane checks every request through role-based rules. These rules are additive, which means there are no deny

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up kubernetes api security by defining strict roles and binding them to users. These rules check every request sent to the cluster control plane. Most teams start by granting broad roles so developers can fix broken apps fast. Over time, those wide roles stay in place and expose live workloads to mistakes.

How kubernetes api security works with native roles

The cluster control plane checks every request through role-based rules. These rules are additive, which means there are no deny rules at all. You start with zero access and add allowed actions one by one. A standard role sets permissions inside a single namespace for one team. A cluster role covers the whole cluster and includes resources like nodes. It can also cover namespaced items across every namespace at once.

To give these rules to a user, you create a binding. A role binding grants permissions inside one namespace to a person or group. That binding can point to a standard role in the same namespace. It can also point to a global cluster role to save time. This lets admins write one common role and reuse it across many teams. In contrast, a cluster role binding grants access across the entire cluster. You should use cluster-wide bindings with great care.

How subresources affect pod logs and shell commands

Role rules match resources by the exact name in the request URL. Some requests target a smaller part of an object called a subresource. Reading pod logs or running a shell inside a pod uses subresources. In your role rules, you write these with a slash after the resource. That lets you separate basic pod reading from shell execution.

A user might have permission to view pods and read their logs. That same user will still get blocked when trying to open a shell. You must grant the pod execution subresource before a shell request works. Admins can also restrict rules to specific resource names for most actions. Still, name limits on create actions only work on top-level resources, not subresources. That limit makes it harder to lock down shell requests to one pod.

Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native controls solve and what they leave open

Native roles and bindings do a great job of blocking unknown users. They stop a developer on team A from deleting pods owned by team B. They also let you separate read-only log checks from live container shells. This gives your platform a strong baseline for daily work.

Still, native rules only check the start of a request. Once the server allows a pod shell or port forward, the check ends. The cluster does not inspect the commands typed inside that open shell. It also cannot rewrite sensitive fields like emails or card numbers in log output. If an engineer needs to run one safe command, they get full shell rights. Standard roles decide who gets in, not what happens inside the live session.

Govern kubectl and API calls in flight

Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.

Frequently asked questions

Can I write a deny rule in native cluster roles?

No, native role rules are additive only and never support deny rules. To block an action, you must remove the rule or binding that grants it.

What is the difference between a role binding and a cluster role binding?

A role binding applies rules inside one single namespace. A cluster role binding applies rules across all namespaces and cluster-level resources.

How do I let a team read pod logs without giving them shell access?

Grant the pod log subresource in their role and leave out the exec subresource. The server will allow log reads and block any shell requests.

The query runs. The emails stay hidden.