How to Configure GitHub Copilot Kubernetes Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up github copilot kubernetes read only access by binding a read role to a scoped user. Then you point your local agent tools to that restricted cluster profile. Many teams give coding agents the same local cluster profile that a human engineer uses. That profile often holds broad admin rights across the whole cluster. If an agent runs the wrong command, it can change or delete live workloads. Limiting the agent to read actions stops it from changing cluster state. How github copilot ku

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 github copilot kubernetes read only access by binding a read role to a scoped user. Then you point your local agent tools to that restricted cluster profile. Many teams give coding agents the same local cluster profile that a human engineer uses. That profile often holds broad admin rights across the whole cluster. If an agent runs the wrong command, it can change or delete live workloads. Limiting the agent to read actions stops it from changing cluster state.

How github copilot kubernetes read only access works in native RBAC

Kubernetes role-based access control uses rules to grant permissions to users and service accounts. These rules are purely additive, which means there are no deny rules in the system. You start with zero access and add only the actions the agent needs. For a read-only setup, you only allow read verbs like get, list, and watch.

You can define these rules at the namespace level or across the whole cluster. A Role sets permissions inside one specific namespace. A ClusterRole sets permissions for cluster-scoped items, like nodes, or across all namespaces at once. After you make the role, you attach it to an identity with a binding. A RoleBinding grants those permissions inside a single namespace. A ClusterRoleBinding grants the permissions across the entire cluster.

To keep the agent safe, create a dedicated identity just for your coding assistant. Bind that identity to a Role or ClusterRole that only includes read verbs. When the agent runs commands from your editor, it uses this limited identity. The cluster API server checks every request against the bound rules. If the agent tries to create, change, or delete a pod, the API server blocks it.

Scoping subresources and secret objects in read roles

Giving read access to all objects in a namespace can still expose sensitive data. A standard read role might let the agent read Secret objects or config maps. If an agent reads a Secret, that raw value enters the prompt context. You must write your role rules carefully so they exclude Secret objects.

You also need to plan how the agent reads subresources like pod logs. In Kubernetes RBAC, subresources appear with a slash in the resource name, such as pods/log. If you want the agent to debug a crash, it needs read access to pods/log. You should avoid granting access to the pods/exec subresource in a read-only role. Opening an interactive shell inside a running pod lets the agent change files or run scripts. Leaving out exec rules keeps the agent strictly on the outside looking in.

Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native RBAC solves and what stays exposed

Native Kubernetes RBAC solves the basic problem of who can run which API verbs. It stops an AI coding assistant from deleting deployments, changing services, or scaling nodes down. It also lets you keep the agent inside one test namespace instead of the whole cluster.

Still, static roles only check who logs in and which API resource they ask for. They do not inspect the content of what comes back from the cluster. For example, an agent with access to pod logs can still pull sensitive customer data. App logs often print emails, phone numbers, card numbers, or national IDs during normal runs. Native RBAC hands the full log stream straight to the local machine and the model. Also, managing separate static credentials on every developer laptop adds work for the platform team. If a local token leaks, anyone with that file has read access until you rotate it.

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

Can I use a deny rule to block GitHub Copilot from reading Kubernetes secrets?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To block secret access, you must leave secrets out of the allowed resources list in your Role.

What is the difference between a RoleBinding and a ClusterRoleBinding for an AI agent?

A RoleBinding limits the agent to a single namespace, even if it references a ClusterRole. A ClusterRoleBinding gives the agent permissions across all namespaces and cluster-scoped resources.

How do I let GitHub Copilot read pod logs without giving it shell access?

Grant read verbs on the pods and pods/log resources in your role rules. Do not include the pods/exec subresource, which prevents the agent from running commands inside containers.

The query runs. The emails stay hidden.