How to Configure MicroK8s Role Binding

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a microk8s role binding by turning on role rules and linking a user to a role. This link gives that user the right to read or change items in one namespace. Most teams start by sharing one main admin key across the whole group. That shared key lets anyone delete workloads or read secret values in every namespace. Scoping roles down to each namespace stops wide mistakes before they happen. How a microk8s role binding works in your cluster MicroK8s ships as a fast, small Kubernetes s

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 a microk8s role binding by turning on role rules and linking a user to a role. This link gives that user the right to read or change items in one namespace. Most teams start by sharing one main admin key across the whole group. That shared key lets anyone delete workloads or read secret values in every namespace. Scoping roles down to each namespace stops wide mistakes before they happen.

How a microk8s role binding works in your cluster

MicroK8s ships as a fast, small Kubernetes setup for local boxes and edge nodes. Out of the box, its role rule add-on stays off to keep setups simple. Everyone with the default client file holds full cluster admin rights. You must enable the role rule add-on first to enforce any user limits.

Once you turn on role rules, the API server checks every request. This system uses three main parts to control who can do what. First, a subject represents the person, group, or app account making a call. Second, a role lists the allowed verbs, like read, list, create, or delete. That role also names the target items, such as pods, services, or logs. Third, the binding joins the subject to the role inside one specific namespace.

You also need a way to prove who the user is during login. Kubernetes does not store user accounts inside its own database like it stores service accounts. Instead, teams issue client certificates, use tokens, or link an external login provider. When a user sends a request, the API server reads their identity first. Next, it checks if a microk8s role binding matches that user in that namespace. If the rule matches, the cluster runs the command and returns the output.

Choosing between namespace bindings and cluster bindings

Kubernetes gives you two ways to link roles to your users and apps. A standard role binding works inside a single namespace that you pick. If you bind a developer to a staging role, they only affect staging pods. They cannot touch production pods or view cluster nodes with that binding.

A cluster role binding works across every namespace and cluster resource at once. Teams use cluster bindings for node admins, monitoring tools, and storage drivers. You can also pair a cluster role with a standard namespace binding. This pattern lets you write one read-only rule and reuse it per namespace. Your team avoids copying the same role text into ten different namespaces.

Session Binding to Device + Role-Based Access Control (RBAC): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native cluster roles solve and where they stop

Native bindings do a great job of blocking unauthorized API calls at the door. You can stop a junior engineer from deleting deployments or editing network rules. You can also restrict service accounts so apps only read their own settings. This setup cuts down the blast radius of a lost token or bad script.

Still, native role rules only check the outer API action at login time. If a developer needs to debug a live container, they need exec rights. Once the cluster grants exec rights, the role check is finished. The cluster cannot inspect the shell commands that run inside that open container. Similarly, if a role allows reading secrets, the user gets every raw value. Native bindings also leave static client files sitting on engineer laptops for months. Revoking a user certificate takes manual work across your cluster nodes. Teams often need deeper controls over live commands, secret values, and human approvals.

Add request guardrails and response masking beside Kubernetes

Cluster roles and service accounts govern who reaches the Kubernetes API. Still, a broad role or agent can delete workloads or print sensitive values from ConfigMaps and logs. In practice, hoop.dev sits inline beside the API server as a sidecar for your Kubernetes API. For every production API call an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review alongside RBAC.

With hoop.dev Kubernetes controls, guardrails allow listing Secret names while refusing reads of Secret data before execution, and data masking redacts matched keys in returned JSON responses and log streams in memory. Furthermore, hoop.dev holds SOC 2 Type II and is MIT licensed on GitHub.

Frequently asked questions

Why does my microk8s role binding not block any commands?

Check if the role rule add-on is active on your MicroK8s node first. Also make sure the user is not still using the default admin client file.

Can one microk8s role binding cover two namespaces at once?

No, a standard binding only applies to the single namespace where you create it. You must create a separate binding in each namespace that the user needs.

How do I let a user read pods without reading secrets?

Create a role that lists only pods and pod logs as allowed resources. Leave secrets off that resource list, and bind the user to that role.

The query runs. The emails stay hidden.