How to Configure K3s Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up k3s read only access by binding a view role to a user. This rule lets engineers check pods and logs while blocking changes to your cluster. Many teams share the default admin file when they first build a cluster. That file grants full control over every node, pod, and secret in the system. One bad command can delete running workloads or expose private keys. Creating a limited role stops bad changes before they break your apps. How to set up k3s read only access with native roles K3

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 k3s read only access by binding a view role to a user. This rule lets engineers check pods and logs while blocking changes to your cluster. Many teams share the default admin file when they first build a cluster. That file grants full control over every node, pod, and secret in the system. One bad command can delete running workloads or expose private keys. Creating a limited role stops bad changes before they break your apps.

How to set up k3s read only access with native roles

K3s uses the standard Kubernetes role system to control what users can do. First, you create an identity for the person or tool that needs to log in. Teams often use a service account or a client certificate for this step. Next, you pick a role that only allows safe actions like get and list. K3s ships with a built-in view role made for this exact job.

This default view role lets users read most objects inside a single namespace. It blocks them from changing deployments, deleting pods, or reading secret values. If an engineer needs to check every namespace, you use a cluster role binding. If they only work on one app, you use a standard role binding. Finally, you generate a new config file tied to that limited account. You send this file to the engineer so they can run safe read commands.

Managing accounts and tokens across multiple clusters

Setting up one role is fast when you only run a single node. The work gets much harder when your team manages dozens of edge clusters. K3s stores its main admin file on the server disk during startup. To add new users, an admin must log in and build new keys by hand. You can link K3s to an outside login tool, but that takes extra setup.

Each cluster needs special startup rules to talk to your main team directory. When someone leaves the team, you must revoke their keys on every cluster. If you use static tokens, those keys stay valid until an admin deletes them. Tracking who holds which file across many servers takes hours of manual work.

Auditor Read-Only Access + Customer Support Access to Production: 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 are great at stopping users from deleting pods or editing configs. They decide who can log in and which API paths they can call. Still, native roles cannot check the actual data flowing back to the user. A read role still lets engineers pull full app logs to their laptops. Those logs often hold user emails, phone numbers, or card numbers from live traffic.

Even if you block secret objects, apps still print private data to standard output. Also, a shared read account hides which specific person ran a command. The cluster log only shows the role name, not the real human behind it. Static config files sitting on laptops can also leak if a device gets lost.

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

Does the default view role hide Kubernetes secrets?

Yes, the built-in view role blocks users from reading or listing secret objects. Still, users can still read pod logs that might print private data in plain text.

How do I limit a user to one namespace in K3s?

You create a role binding inside that single namespace instead of a cluster binding. This rule restricts their read checks to that specific area of the cluster.

How can I revoke a static K3s config file?

If the file uses a service account token, you delete the account or secret. If it uses a client certificate, you must rotate the cluster certificate authority.

The query runs. The emails stay hidden.