Kubernetes Security Monitoring

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up kubernetes security monitoring by turning on API audit logs and role rules. These native controls track who talks to the cluster and check every API call. Most teams start by assigning cluster roles to user groups and logging API events. When teams give out broad roles to fix issues fast, risky actions go unseen. Engineers can run live commands inside containers or read sensitive logs without clear limits. How native kubernetes security monitoring works Kubernetes controls cluster

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 security monitoring by turning on API audit logs and role rules. These native controls track who talks to the cluster and check every API call. Most teams start by assigning cluster roles to user groups and logging API events. When teams give out broad roles to fix issues fast, risky actions go unseen. Engineers can run live commands inside containers or read sensitive logs without clear limits.

How native kubernetes security monitoring works

Kubernetes controls cluster actions through role-based rules on the API server. A Role sets permissions inside one single namespace. A ClusterRole sets rules across the whole cluster. It can cover cluster nodes, non-resource endpoints, or namespaced items across every namespace. You connect users to these rules with a RoleBinding or a ClusterRoleBinding. A RoleBinding grants permissions inside one namespace and can point to a ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once.

In Kubernetes, all permission rules are additive. There are no deny rules in this system. You only list the actions a user can take. The API server checks each request against these rules before it runs. Some API requests target a subresource, such as pod logs or pod exec sessions. RBAC rules write these subresources with a slash between the resource and the action. Every time a user makes a request, the API server can record the event.

What native roles solve and what they miss

Native roles and bindings do a good job of guarding the front door. They decide which user or service account can call a specific API endpoint. You can limit a team to one namespace with a standard RoleBinding. You can also block users from reading secrets or changing deployment files.

Still, native rules only check the initial API call. Once a user starts an exec session in a pod, the API check ends. The cluster logs that the session started, not the shell commands run inside. Also, subresource rules have limits when you restrict access by specific resource names. And when an engineer reads pod logs, raw data flows straight to their screen. Native roles do not rewrite emails, phone numbers, or card numbers in that output. Teams cannot ask for quick peer approval on a single command, either. A user either holds the role all day or cannot run the command.

Kubernetes Operator for Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Closing the gap in live cluster sessions

To get full visibility, teams must watch what happens after the API call passes. You need controls that inspect individual commands and data streams in flight. Instead of granting permanent shell access, teams can approve single tasks on demand. Data masking can also rewrite national IDs or card numbers in log streams. This keeps day-to-day debugging fast while keeping sensitive data safe during live work.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.

Frequently asked questions

Can Kubernetes RBAC deny a specific command inside a pod?

No, Kubernetes RBAC rules are additive and have no deny rules. Once RBAC allows a pod exec subresource call, it cannot filter shell commands inside.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one namespace, even when it points to a ClusterRole. A ClusterRoleBinding grants permissions across all namespaces and cluster resources at once.

How does Kubernetes handle permissions for pod logs and exec sessions?

Kubernetes treats pod logs and exec sessions as subresources in the API. You must grant permissions to those specific subresources in your Role or ClusterRole rules.

The query runs. The emails stay hidden.