Kubernetes Application Security

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams build kubernetes application security by setting strict role rules and limiting pod access. You grant each user or service only the actions they need in one namespace. Most teams start by assigning default admin roles to help developers ship code fast. When permissions stay too broad, one bad command can harm every running app. How kubernetes application security works with native RBAC The platform controls access through its built-in role-based access control system. You turn this mode

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.

Teams build kubernetes application security by setting strict role rules and limiting pod access. You grant each user or service only the actions they need in one namespace. Most teams start by assigning default admin roles to help developers ship code fast. When permissions stay too broad, one bad command can harm every running app.

How kubernetes application security works with native RBAC

The platform controls access through its built-in role-based access control system. You turn this mode on at the API server to check every request. Every rule in this system is additive, which means there are no deny rules. You start with zero access and add specific permissions for each team or app.

Two main objects hold these permission rules. A Role sets rules inside a single namespace for local items like pods. A ClusterRole sets rules across the whole cluster. It can cover cluster-wide items like nodes, or namespaced items across all namespaces.

After you write the rules, you attach them to users with a binding. A RoleBinding grants those permissions inside one specific namespace. You can point a RoleBinding at a local Role or a shared ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. For safety, teams prefer local bindings so apps stay isolated in their own namespace.

Controlling pod logs and command execution

Protecting an app also means controlling who can read logs or run commands inside pods. In the API, features like pod logs and command execution are subresources. You write these rules using a slash between the main resource and the subresource. This lets you allow log reading without allowing command execution.

Many teams grant pod execution access so engineers can fix live bugs. If you grant broad subresource access, a user can open a shell in any pod. From there, they can read local files or change how the app runs. Restricting rules by specific resource names also has limits on creation requests for subresources. Teams must separate read roles from interactive shell roles.

Application-to-Application Password Management + Kubernetes Operator for Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native roles and bindings do a great job of guarding the cluster API. They verify who can start a pod, read a log, or open a shell. They also keep workloads separated by namespace when you avoid cluster-wide bindings.

Still, native access rules only check the initial API request. Once the API server allows a shell session into a pod, its job ends. Native RBAC does not inspect the individual commands a user types inside that shell. It also cannot rewrite sensitive output like emails, phone numbers, card numbers, or national IDs. If an engineer runs a database tool inside a pod, RBAC sees only the shell start. Teams still need a way to check live commands and protect sensitive data in flight.

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 Kubernetes RBAC?

No, permissions in the native RBAC system are purely additive. You must start with no permissions and grant only the exact actions a user needs.

When should I use a RoleBinding instead of a ClusterRoleBinding?

Use a RoleBinding whenever a user or app only needs access inside one namespace. You can bind a shared ClusterRole with a RoleBinding to keep permissions inside that single namespace.

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

Create a Role that grants access only to the pod log subresource. Leave the pod exec subresource out of the role so users cannot open a shell.

The query runs. The emails stay hidden.