Openshift Security Hardening

Published
Length
3 min read

Luis Felipe Dias

All posts

You start openshift security hardening by locking down role rules and cluster permissions. You must limit who can run commands inside pods and read cluster secrets. Most teams start by setting up broad admin roles to ship apps fast. That approach leaves wide gaps across namespaces when an engineer runs a bad command. Overly broad roles let one mistake impact every running workload in the cluster. How openshift security hardening works with role rules Under the hood, the platform uses the nati

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 start openshift security hardening by locking down role rules and cluster permissions. You must limit who can run commands inside pods and read cluster secrets. Most teams start by setting up broad admin roles to ship apps fast. That approach leaves wide gaps across namespaces when an engineer runs a bad command. Overly broad roles let one mistake impact every running workload in the cluster.

How openshift security hardening works with role rules

Under the hood, the platform uses the native Kubernetes role system to check requests. A Role or ClusterRole holds rules that represent a set of permissions. These permissions are additive, which means there are no deny rules in the system. You only grant what a user or service account needs to do a job.

A Role always sets permissions within one single namespace for your team. A ClusterRole is not namespaced and can cover cluster-scoped resources like nodes. It can also cover non-resource endpoints or namespaced resources across all namespaces. Teams must pick the right scope so permissions do not bleed across projects.

Once you write a role, you link it to users with a binding. A RoleBinding grants permissions inside one specific namespace for a user or group. That RoleBinding can reference a Role in that same namespace or a shared ClusterRole. In contrast, a ClusterRoleBinding grants access across the entire cluster at once. For strong openshift security hardening, bind users to single namespaces instead of the whole cluster.

Controlling pod subresources and runtime actions

Standard resource rules are not enough to stop risky actions inside running containers. The API server refers to resources by the exact name in the API URL. Some APIs use a subresource, such as reading a pod's logs or running commands. In the role rule, you write the subresource with a slash.

For example, you grant log reading by naming the pods and log subresource. You control interactive shell sessions by naming the pods and exec subresource. If a role allows the exec subresource, that user can open a shell inside containers. Teams must keep log roles separate from exec roles to limit live container changes.

OpenShift RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they miss

Native roles and bindings do a great job of gatekeeping at the API door. They decide which user can read pod logs or start an interactive pod session. This stops unauthorized users from entering namespaces they do not own or manage.

Still, native role checks stop once the API server approves the initial request. When an engineer gets exec permissions to fix a bug, the role check ends. The native system does not check individual commands run inside that open container shell. It also cannot mask sensitive data like emails or card numbers in query output. Teams still face risks from broad shell sessions and exposed secrets during live debugging.

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

Can I write a deny rule to block specific cluster actions?

No, native role permissions are additive and do not support deny rules. You must start with zero permissions and only add the exact rules required.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one specific namespace only. A ClusterRoleBinding grants permissions across all namespaces and cluster-scoped resources.

How do I let developers read pod logs without giving shell access?

Grant access only to the pod log subresource in their namespace role. Leave the pod exec subresource out of the role so they cannot open shells.

The query runs. The emails stay hidden.