How to Configure MicroK8s Cluster Role

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a microk8s cluster role by turning on role-based access control and defining rules for cluster resources. Next, you bind that role to a user, group, or service account across the whole cluster. Many teams start by giving developers broad admin rights to speed up local or edge testing. Still, overly broad permissions let a single mistake or stolen token wipe out shared workloads across every namespace. How a microk8s cluster role works in practice A standard role in Kubernetes only

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 cluster role by turning on role-based access control and defining rules for cluster resources. Next, you bind that role to a user, group, or service account across the whole cluster. Many teams start by giving developers broad admin rights to speed up local or edge testing. Still, overly broad permissions let a single mistake or stolen token wipe out shared workloads across every namespace.

How a microk8s cluster role works in practice

A standard role in Kubernetes only controls permissions inside a single namespace. A microk8s cluster role works across all namespaces and also governs cluster-scoped objects like nodes and persistent volumes. Before these rules take effect, you must enable the native role-based access control add-on in your node setup.

Once you turn on the add-on, the API server checks every request against your defined rules. Each rule lists the API groups, the target resources, and the allowed verbs like get, list, watch, or delete. A role does nothing on its own until you attach it to an identity. You create a cluster role binding to link the role to a specific user or service account.

Teams also use a microk8s cluster role as a reusable template for smaller scopes. If you link a cluster role using a standard namespace binding, the user gets those permissions only inside that one namespace. This pattern saves time when many teams need the same read or write rules in their own spaces.

What native roles solve and what they miss

Native cluster roles solve the first layer of cluster security by enforcing coarse permissions at the API level. They stop unauthorized users from reading secrets in other namespaces or deleting critical node resources. You can split duties between platform admins, app developers, and automated pipelines with clear YAML definitions.

Yet native roles leave a big operational gap once a user has valid access. A role decides who can run a pod execution command or read a secret object. It does not inspect the exact shell commands a user runs inside a container session. If an engineer needs to fix a live pod, they often get broad exec or write rights that stay active all day.

Static client files on laptops also create risk when team members change roles or leave. Also, native API logs record that an exec call started. However, they do not capture the terminal output or filter sensitive data like emails, phone numbers, card numbers, or national IDs. Teams need a way to govern individual commands in flight and remove standing credentials from user machines.

K8s RBAC Role vs ClusterRole + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Best practices for scoping cluster permissions

Start every user and service account with zero cluster-wide rights by default. Grant permissions at the namespace level first, and only use a cluster-wide binding when a tool truly reads nodes or all namespaces. Avoid wildcard verbs and wildcard resource rules in your custom role definitions.

Split human roles from machine roles so automated agents do not share admin profiles with engineers. Review your role bindings on a regular schedule to remove stale accounts and unused privileges. When someone needs elevated rights to fix a production issue, scope that access to the exact task and revoke it right after.

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 sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. 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

When should I use a cluster role instead of a regular role?

Use a cluster role when a user or tool needs to view or change cluster-scoped objects like nodes or storage classes. You also use it when a monitoring tool must read pods across every namespace at once.

Why are my cluster role rules not blocking unauthorized users?

MicroK8s ships with role-based access control turned off by default to keep initial setup simple. You must enable the RBAC add-on on your node before the API server enforces any role bindings.

Can a cluster role restrict access to a single namespace?

Yes, you can define a common set of permissions in one cluster role and attach it with a standard role binding. That binding limits the permissions to the single namespace where you created the binding.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

The query runs. The emails stay hidden.