Securing Kubernetes Dashboard
Securing kubernetes dashboard starts with strict role-based rules on the cluster API server. You must bind each user or service account to the smallest possible role. Many teams set up this web view with wide cluster roles to save time. When roles are too broad, anyone who logs in can change pods across namespaces. A leaked token can expose secrets or let an attacker run commands in containers. How securing kubernetes dashboard works with native roles The dashboard does not have its own separ
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.
Securing kubernetes dashboard starts with strict role-based rules on the cluster API server. You must bind each user or service account to the smallest possible role. Many teams set up this web view with wide cluster roles to save time. When roles are too broad, anyone who logs in can change pods across namespaces. A leaked token can expose secrets or let an attacker run commands in containers.
How securing kubernetes dashboard works with native roles
The dashboard does not have its own separate rule system. Instead, it uses the native role-based system built into the Kubernetes API server. Every rule in this system is purely additive. There are no deny rules in Kubernetes role definitions. You start with zero permissions and add only the actions a team member needs.
To keep rules tight, you choose between two role types. A Role sets permissions inside one single namespace. A ClusterRole is not tied to one namespace. It can cover cluster-wide objects like nodes, or objects across every namespace. For most app teams, a single namespace Role is the safest choice.
Once you define a Role, you connect it to a user with a RoleBinding. A RoleBinding grants permissions inside one specific namespace. It can point to a Role in that same namespace. It can also point to a reusable ClusterRole while keeping permissions inside that one namespace. By contrast, a ClusterRoleBinding grants access across the whole cluster. You should avoid cluster-wide bindings for standard dashboard users.
Why subresources matter for dashboard permissions
The dashboard lets users do more than just view pod names. Users can also read container logs or open a shell inside a running pod. In the API server, these actions use subresources. The rule system writes subresources with a slash, such as pods and log or pods and exec.
If you grant a wildcard rule on pods, you also grant shell and log rights. A user who only needs to check pod status should not have exec rights. You must list allowed resources and subresources one by one in your role rules. This stops dashboard users from opening interactive shells in production containers when they only need view rights.
Kubernetes RBAC + GitLab Security Dashboard: 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 decide who can log in and which API paths they can call. They are great at keeping an app team inside its own namespace. They also block users from reading secret objects or opening pod shells if you leave those rules out.
Still, native roles stop checking once the API call passes the gate. If an engineer needs pod exec rights to fix a live bug, the role allows the whole shell session. Native rules cannot see or filter the individual commands run inside that container shell. They also cannot mask sensitive data like emails, phone numbers, card numbers, or national IDs printed in pod logs. The cluster knows who opened the session, but not what happened inside it.
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 I add a deny rule to block one specific namespace in the dashboard?
No, Kubernetes permissions are purely additive and do not support deny rules. To block a namespace, avoid ClusterRoleBindings and grant access only with single-namespace RoleBindings.
How do I let dashboard users view pod logs without granting shell access?
Add the pod log subresource to their Role and leave out the pod exec subresource. This lets them read output in the browser without running commands inside the container.
Can a ClusterRole be used for a single namespace in the dashboard?
Yes, you can reference a ClusterRole inside a standard RoleBinding. This applies the ClusterRole rules only within the single namespace where the RoleBinding lives.
Related guides
In this post