How to Configure Amazon Q Kubernetes Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You can set up amazon q kubernetes read only access with a dedicated RBAC role. Bind that role to the credentials your AI assistant uses for cluster commands. Many engineering teams start by sharing a personal admin kubeconfig on a local machine. That shortcut lets an automated assistant change or delete live workloads by mistake. A strict read-only role stops the tool from making direct state changes. Still, native cluster permissions still leave gaps around secret values and sensitive log outp

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 can set up amazon q kubernetes read only access with a dedicated RBAC role. Bind that role to the credentials your AI assistant uses for cluster commands. Many engineering teams start by sharing a personal admin kubeconfig on a local machine. That shortcut lets an automated assistant change or delete live workloads by mistake. A strict read-only role stops the tool from making direct state changes. Still, native cluster permissions still leave gaps around secret values and sensitive log output.

How amazon q kubernetes read only access works in native RBAC

Amazon Q runs local shell commands or tool calls on behalf of the developer. When the assistant checks cluster state, it uses the local kubeconfig file to talk to the API server. Kubernetes RBAC checks every API request against the rules bound to that user or service account.

In Kubernetes, permissions are additive, which means there are no deny rules. You build a read-only profile by starting with zero access and adding view verbs. A Role sets permissions inside a single namespace. A ClusterRole sets permissions across the whole cluster, including nodes and all namespaces.

A RoleBinding applies those rules to a user or group inside one namespace. A ClusterRoleBinding applies a ClusterRole across the entire cluster at once. To keep the assistant from changing workloads, you grant only read verbs like get, list, and watch. You leave out write verbs such as create, update, patch, and delete.

Subresources need special care when you write these rules. Kubernetes treats pod logs and pod exec sessions as subresources in the API URL. You can allow pod log reads so the assistant can help debug failing containers. At the same time, you must leave out the pod exec subresource. That stops the assistant from opening a shell inside a running container.

Why native RBAC roles are not enough for AI assistants

Native Kubernetes RBAC solves the first part of the security problem. It checks who is logging in and blocks write verbs at the API server. If the assistant tries to delete a deployment, the cluster rejects the request right away.

Still, static RBAC rules only decide which resource types a role can read. They do not inspect the actual data inside those resources or commands in flight. A cluster-wide view role often includes read access to ConfigMaps and Secrets. If a role can list secrets, the assistant can read API keys and database passwords. Even without secret access, pod logs and config files often contain customer data.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When the assistant reads pod logs to fix an error, those logs flow into the model context. Those log lines can include emails, phone numbers, card numbers, or national IDs. Native RBAC cannot rewrite matched fields in results before they reach the client. It grants all-or-nothing access to the log endpoint.

Static kubeconfig files on developer laptops also create key management issues. A local token stays valid until someone rotates it or revokes the binding. Teams also lack a clear audit trail that links specific prompts to individual cluster API calls. Native cluster logs show the service account name, but not why the command ran.

Scoping namespaces and subresources for safer debugging

You can reduce risk by avoiding cluster-wide bindings whenever possible. Create a separate Role and RoleBinding inside each non-production namespace instead. This limits the assistant to reading workloads in one project area at a time.

When you define the role rules, list each safe resource type by name. Include pods, deployments, services, events, and pod logs. Leave Secrets out of the resource list so the role cannot pull stored credentials. This setup helps with basic status checks, though it still cannot filter sensitive strings out of app logs.

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 runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.

With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. 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 Kubernetes RBAC block an AI assistant from running pod exec commands?

Yes, Kubernetes treats pod exec as a distinct subresource in RBAC rules. If you only grant read verbs on pods and pod logs, the API server blocks exec requests. Always check that your role does not include create or get verbs on the exec subresource.

Does a read-only ClusterRole hide Kubernetes Secrets from Amazon Q?

It depends on which resources are listed in the ClusterRole rules. Because Kubernetes permissions are additive, you must leave Secrets out of the allowed resource list. Keep in mind that environment variables on pod specs or app logs may still expose sensitive values.

Should I use a RoleBinding or a ClusterRoleBinding for AI debugging?

A RoleBinding is safer for daily work because it restricts access to a single namespace. You can reference a shared read-only ClusterRole inside a namespace-scoped RoleBinding. This lets you reuse one rule definition without granting access to the whole cluster.

The query runs. The emails stay hidden.