How to Configure OpenShift Kubeconfig

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openshift kubeconfig file by logging into the cluster and saving your context. This local file stores cluster endpoints, user credentials, and active namespaces for your command tool. Most engineering teams start by sharing static admin files or broad cluster roles during setup. Over time, these broad roles give too many people full control over live workloads. How an openshift kubeconfig works with cluster roles Your local config file tells the command client which cluster serv

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 an openshift kubeconfig file by logging into the cluster and saving your context. This local file stores cluster endpoints, user credentials, and active namespaces for your command tool. Most engineering teams start by sharing static admin files or broad cluster roles during setup. Over time, these broad roles give too many people full control over live workloads.

How an openshift kubeconfig works with cluster roles

Your local config file tells the command client which cluster server to reach. It also holds the client certificate or bearer token that proves your identity. Once the server checks who you are, role-based access control takes over.

In Kubernetes, a Role or ClusterRole holds rules that represent a set of permissions. These permissions are purely additive, which means there are no deny rules in the system. A Role always sets permissions within a single namespace. A ClusterRole is not namespaced and can cover cluster-wide resources like nodes. It can also cover non-resource endpoints or namespaced resources across all namespaces.

To grant these rules to a user in your config file, you create a binding. A RoleBinding grants permissions within one specific namespace. It can point to a Role in that same namespace or a shared ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once.

So, the openshift kubeconfig file only handles the first half of the login flow. It gets your request to the API server with a valid user identity. The server then checks your bindings to see if your user can run that action.

Managing subresources and daily team access

Teams must also think about subresources when they set up cluster roles for engineers. Role rules refer to resources by the exact name that appears in the API path. Some APIs involve a subresource, such as reading pod logs or running commands inside containers. In role rules, you write the subresource with a slash between the resource and action.

OpenShift RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Developers often need to read pod logs or open a shell to fix broken apps. Admins grant these subresource rules so teams can debug issues on their own. When teams manage many clusters, keeping all these local config files updated gets hard. Engineers store tokens on their laptops, and those files can sit on disks for months. If a laptop is lost, anyone with that file can reach the cluster API.

What native config files and roles leave open

Native roles and config files solve the basic problem of who can reach the cluster. They verify user identities and check if a user can touch a specific resource type. Still, this setup only decides who logs in and which API paths they can call.

Once an engineer opens an interactive pod shell, native role rules stop inspecting the session. The cluster knows the user started a shell, but it does not check individual commands. An engineer with shell access can read local container files or query linked data stores. Native roles also cannot mask sensitive fields like emails, phone numbers, card numbers, or national IDs. If pod logs print out user data, anyone with log access sees the raw text. Teams need a way to control commands in flight and protect data inside the session.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.

Frequently asked questions

What is stored inside an openshift kubeconfig file?

The file stores cluster API addresses, user tokens or certificates, and context mappings. A context links a specific user identity to a cluster and a default namespace. This lets you switch between different clusters and projects without logging in again.

How do RoleBindings differ from ClusterRoleBindings?

A RoleBinding applies permissions inside a single namespace for a specific team or project. A ClusterRoleBinding applies permissions across every namespace and cluster-level resource at the same time. You can pair a RoleBinding with a ClusterRole to reuse common rules in one namespace.

Why can we not add deny rules to restrict a broad kubeconfig user?

Kubernetes role permissions are purely additive by design and do not support deny rules. To restrict a user, you must remove their broad binding and assign a smaller role. You always start with zero access and add only the exact verbs the user needs.

The query runs. The emails stay hidden.