Skip to main content

More Info:

The cluster-admin ClusterRole grants unrestricted access to every API. Bind it only to a small, audited set of break-glass identities; daily operations should use scoped roles.

Risk Level

High

Address

Compliance, Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Using Console

Below is how to tighten and restrict cluster-admin usage for an OKE cluster using only the OCI Console (with Cloud Shell and kubectl).

1. Open the OKE cluster in OCI Console

  1. Sign in to the OCI Console.
  2. In the left menu, go to Developer Services → Kubernetes Clusters (OKE).
  3. Select the Compartment that contains your cluster.
  4. Click the name of the target OKE cluster.

2. Get kubeconfig for the cluster

  1. On the cluster details page, click Access Cluster.
  2. In the panel that opens:
    • Choose Cloud Shell as the client environment (or “Local” if you prefer local kubectl, but Cloud Shell keeps you in console).
    • Copy the kubectl / kubeconfig command snippet shown under Cloud Shell.
Example (you’ll see something similar):

3. Open Cloud Shell and configure kubectl

  1. In the top-right of the OCI Console, click the Cloud Shell icon (>_).
  2. When Cloud Shell opens, paste and run the create-kubeconfig command you copied.
  3. Test connectivity:
If you see nodes listed, you’re connected.

4. Identify who currently has cluster-admin

In Cloud Shell:
Look for bindings that reference the cluster-admin ClusterRole, for example:
Take note of:
  • Bindings that give cluster-admin to broad subjects, e.g.:
    • system:authenticated
    • system:serviceaccounts
    • Wildcard-like or large external groups
  • Any custom ClusterRoleBinding whose roleRef.name is cluster-admin.

5. Remove or tighten dangerous ClusterRoleBindings

5.1. Delete overly broad ClusterRoleBindings

If you find a binding such as:
Inspect it:
If it is broad (e.g., system:authenticated or a large IAM group), delete it:
Repeat for any other non-essential or overly broad cluster-admin bindings.Do NOT delete the critical system bindings you don’t fully understand (e.g., system ones created by OKE / Kubernetes), unless you are sure they’re not required.

6. Replace cluster-admin with least-privilege roles

Instead of giving cluster-admin, create narrow roles and bind them.

6.1. Create a least-privilege ClusterRole (example)

In Cloud Shell, create a file:
Apply it:

6.2. Bind specific users/groups to the limited role

Example binding a specific group:
Apply:
This way, people who previously had cluster-admin get only the permissions they actually need.

7. Restrict who can reach cluster-admin via OCI IAM

OKE access is a combination of:
  • OCI IAM Policies (who can manage or use clusters and node pools)
  • Kubernetes RBAC (what they can do inside the cluster)
To restrict who can even talk to the cluster as admins:
  1. In the OCI Console, go to Identity & Security → IAM → Policies.
  2. In the correct compartment / tenancy, locate policies like:
  3. Tighten them as needed:
    • Limit to a smaller group (e.g., oke-admins).
    • Change manage to use if full management is not required.
  4. Save the updated policy.
This reduces who can obtain kubeconfigs and then become cluster admins.

8. Verify the restriction

  1. In Cloud Shell:
    It should return no (or only yes for allowed verbs/resources).
  2. Confirm that only designated admins (limited group) have the permissions they need.

If you tell me how cluster-admin is currently granted in your OKE (e.g., sample clusterrolebinding output), I can give you an exact “before/after” YAML to apply.
Below is a practical, step‑by‑step way to restrict cluster-admin usage in OKE, focusing on OCI CLI (plus kubectl, which you invoke after generating kubeconfig via OCI CLI).

0. Prereqs

  • OCI CLI configured with a user that has permission to manage IAM and OKE.
  • kubectl installed.
  • You know:
    • Your compartment OCID.
    • Your cluster OCID.
    • The tenancy or IAM group OCIDs you want to allow as cluster admins.

1. Tighten OCI IAM access to the cluster

Cluster-admin in OKE is only possible if OCI IAM lets a user manage the cluster and generate kubeconfigs. First restrict who can do that.

1.1 List current policies

Inspect policies that look like:
And especially any that are overly broad:

1.2 Update policies to narrow access

Example: restrict cluster management to a dedicated group oke-admins.
  1. Create a JSON file policy-statements.json:
  1. Update an existing policy:
  1. Remove or modify any policies that give broader rights than needed (e.g., manage all-resources in tenancy) to regular users/groups.

2. Generate admin kubeconfig only for the right IAM group

Make sure only your intended admin group members can get a kubeconfig with admin‑level access.For an admin user in the oke-admins group:
Then:
Confirm access:
Ensure other users/groups that should NOT be cluster-admin:
  • Do not have policies allowing manage cluster-family (step 1),
  • Or only have limited policies (e.g., use cluster-family / specific verbs).

3. Restrict Kubernetes cluster-admin RBAC

Now restrict actual Kubernetes RBAC bindings that grant the cluster-admin ClusterRole.

3.1 List all cluster-admin bindings

Also inspect all bindings:
Look for subjects (users/groups/serviceaccounts) that should not have admin.

3.2 Remove or replace broad cluster-admin bindings

Common problematic ones:
  • Bindings granting cluster-admin to a wide group like system:masters or to all authenticated users.
Delete unwanted ClusterRoleBindings:
Examples:
If a binding is valid but has too many subjects, you can patch it:
(Adjust group name as needed.)

3.3 Create a minimal, explicit cluster-admin binding for your admin group

Create cluster-admin-oke-admins.yaml:
Apply:
This ensures only the Kubernetes group oke-admins (mapped from your OCI IAM group via OKE auth) has full cluster-admin rights.

4. Validate

  1. As an admin (in oke-admins):
  1. As a non‑admin user (with a separate kubeconfig):
  1. Confirm only your intended bindings reference cluster-admin:

If you provide your current policy statements and any clusterrolebinding YAML, I can give you exact oci and kubectl commands tailored to your environment.
To restrict cluster-admin usage in an OCI OKE cluster using Python, you essentially need to:
  1. Connect to the OKE cluster’s Kubernetes API.
  2. Enumerate all ClusterRoleBinding objects that reference cluster-admin.
  3. Remove or tighten those bindings so only specific, approved subjects (users/groups/service accounts) retain cluster-admin.
Below is a step‑by‑step approach and example Python code using the Kubernetes Python client.

1. Prerequisites

  1. Have kubectl access to the OKE cluster (so your kubeconfig works):
  2. Install Python dependencies:
  3. Ensure your Python environment can read the same kubeconfig used by kubectl (usually $HOME/.kube/config).

2. Decide Your Policy

Before running the script, decide:
  • Which subjects are allowed to have cluster-admin:
    • Type: User, Group, or ServiceAccount
    • Namespaces (only for ServiceAccount)
    • Names (e.g., oke-cluster-admins group)
For example, you might allow only:

3. Python Script: Audit and Remediate cluster-admin Bindings

This script:
  • Connects to the cluster using local kubeconfig.
  • Lists all ClusterRoleBinding objects.
  • Finds those whose roleRef.name == "cluster-admin".
  • For each such binding:
    • Keeps only approved subjects.
    • If no approved subjects remain, deletes the binding.
    • If some remain, updates the binding with a reduced subject list.

4. Run the Script

Review the output and verify:

To fully align with the control:
  • Ensure OCI IAM groups mapped to cluster access do not automatically grant cluster-admin via kubeconfig generation or admission policies.
  • Use more restrictive Kubernetes ClusterRole / Role bindings for regular dev/ops groups instead of cluster-admin.
If you tell me how you currently map OCI IAM groups to Kubernetes RBAC (e.g., via kubeconfig or admission-controller rules), I can provide a Python/OCI-SDK snippet for that side as well.
This change is in-place for the OKE cluster (no cluster replacement), but it will replace or update the ClusterRoleBinding objects if they already exist with a different configuration.If you currently have broad cluster-admin bindings created outside Terraform (for example, bindings to system:authenticated or wide groups), you must either:
  • Import them into Terraform as kubernetes_cluster_role_binding_v1 resources and then narrow their subject blocks, or
  • Remove them manually with kubectl delete clusterrolebinding NAME so only the controlled Terraform-managed binding remains.
Verification: terraform plan should show creation or in-place update of kubernetes_cluster_role_binding_v1.cluster_admin_break_glass (and any other RBAC objects you added), with roleRef targeting cluster-admin and only the intended “break-glass” identities listed under subject.