Add Secret Openshift Cluster

Published
Length
3 min read

Luis Felipe Dias

All posts

To add secret openshift cluster objects, you grant write permissions on the secret resource. You bind a role with create and update rules to a user or service account. Most teams assign broad roles to help engineers ship apps fast. When roles are too broad, anyone with cluster access can read or change sensitive keys. How to add secret openshift cluster objects with native roles OpenShift uses the core Kubernetes role system to control who can manage secrets. In this system, a Role or a Clust

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.

To add secret openshift cluster objects, you grant write permissions on the secret resource. You bind a role with create and update rules to a user or service account. Most teams assign broad roles to help engineers ship apps fast. When roles are too broad, anyone with cluster access can read or change sensitive keys.

How to add secret openshift cluster objects with native roles

OpenShift uses the core Kubernetes role system to control who can manage secrets. In this system, a Role or a ClusterRole holds a set of permission rules. These rules are purely additive, which means there are no deny rules at all. You must declare every allowed action on the secret resource.

A standard Role sets permissions inside one single namespace. This is the safest place to start when a team needs to store app keys. You create a Role that allows create, get, and patch verbs on secrets. Then you create a RoleBinding in that same namespace. The RoleBinding connects the Role to the team user or group.

Sometimes an admin needs to manage secrets across every namespace in the cluster. For this task, you use a ClusterRole instead of a single Role. A ClusterRole is not tied to one namespace. It can cover resources across all namespaces at once. When you pair it with a ClusterRoleBinding, the user gets secret access cluster-wide.

You can also mix these two objects to save time. A RoleBinding in one namespace can reference a shared ClusterRole. This lets you define the secret rules once and reuse them in specific projects.

Where native secret roles fall short in daily work

Native roles do a good job of deciding who can call the API server. They check if a user can create or read a secret object in a namespace. Once that check passes, the native role does not inspect what happens next.

In real work, engineers often need to debug live pods that mount these secrets. Native roles treat pod execution and pod logs as subresources under the pod API. If a role allows pod execution, a user can open a shell inside the container. From that shell, they can read mounted secret files or environment values directly.

OpenShift RBAC + Secret Detection in Code (TruffleHog, GitLeaks): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Even if you restrict direct secret reads, broad pod permissions still expose the keys. Also, native roles are static. When an engineer needs to fix a broken secret during an outage, they need write rights. Teams often grant standing admin roles so engineers do not get blocked at night. Those standing roles stay active long after the fix is done.

How to tighten secret permissions and pod access

First, scope every secret role to a single namespace using a RoleBinding. Avoid ClusterRoleBindings for human users whenever you can. Separate the role that creates secrets from the role that views pod logs.

Second, review who has permission to run commands in pods through the execution subresource. Treat pod shell access with the same care as direct secret read access. A user who can run commands in a pod can read every secret mounted there.

Third, move away from standing write permissions for human accounts. Let automated pipelines write secrets during normal builds. Keep human access focused on short, reviewed tasks with clear command logs and field masking for emails, phone numbers, card numbers, and national IDs.

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 runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. 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

Can I block one user from a secret using a deny rule?

No, native Kubernetes role permissions are purely additive and have no deny rules. To block access, you must remove the binding that grants the permission.

What is the difference between a RoleBinding and a ClusterRoleBinding for secrets?

A RoleBinding grants secret permissions inside one specific namespace only. A ClusterRoleBinding grants secret permissions across the entire cluster and all namespaces.

Can a user without secret read permissions still find secret values?

Yes, if their role allows pod execution on a pod that mounts the secret. They can run a command inside the pod to print the mounted secret files.

The query runs. The emails stay hidden.