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
HighAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below is how to tighten and restrict
2. Get
3. Open Cloud Shell and configure
If you see nodes listed, you’re connected.
4. Identify who currently has
In Cloud Shell:Look for bindings that reference the Take note of:
Inspect it:If it is broad (e.g., Repeat for any other non-essential or overly broad
6. Replace
Instead of giving Apply it:Apply:This way, people who previously had
If you tell me how
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
- Sign in to the OCI Console.
- In the left menu, go to Developer Services → Kubernetes Clusters (OKE).
- Select the Compartment that contains your cluster.
- Click the name of the target OKE cluster.
2. Get kubeconfig for the cluster
- On the cluster details page, click Access Cluster.
- 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/kubeconfigcommand snippet shown under Cloud Shell.
- Choose Cloud Shell as the client environment (or “Local” if you prefer local
3. Open Cloud Shell and configure kubectl
- In the top-right of the OCI Console, click the Cloud Shell icon (
>_). - When Cloud Shell opens, paste and run the create-kubeconfig command you copied.
- Test connectivity:
4. Identify who currently has cluster-admin
In Cloud Shell:cluster-admin ClusterRole, for example:- Bindings that give cluster-admin to broad subjects, e.g.:
system:authenticatedsystem:serviceaccounts- Wildcard-like or large external groups
- Any custom ClusterRoleBinding whose
roleRef.nameiscluster-admin.
5. Remove or tighten dangerous ClusterRoleBindings
5.1. Delete overly broad ClusterRoleBindings
If you find a binding such as:system:authenticated or a large IAM group), delete it: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:6.2. Bind specific users/groups to the limited role
Example binding a specific group: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)
- In the OCI Console, go to Identity & Security → IAM → Policies.
-
In the correct compartment / tenancy, locate policies like:
-
Tighten them as needed:
- Limit to a smaller group (e.g.,
oke-admins). - Change
managetouseif full management is not required.
- Limit to a smaller group (e.g.,
- Save the updated policy.
8. Verify the restriction
-
In Cloud Shell:
It should return
no(or onlyyesfor allowed verbs/resources). - 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.Using CLI
Using CLI
Below is a practical, step‑by‑step way to restrict
Inspect policies that look like:And especially any that are overly broad:
Then:Confirm access:Ensure other users/groups that should NOT be cluster-admin:
3. Restrict Kubernetes
Now restrict actual Kubernetes RBAC bindings that grant the 3.1 List all
Also inspect all bindings:Look for subjects (users/groups/serviceaccounts) that should not have admin.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
Create Apply:This ensures only the Kubernetes group
If you provide your current policy statements and any
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.
kubectlinstalled.- 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
1.2 Update policies to narrow access
Example: restrict cluster management to a dedicated groupoke-admins.- Create a JSON file
policy-statements.json:
- Update an existing policy:
- Remove or modify any policies that give broader rights than needed (e.g.,
manage all-resourcesin 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 theoke-admins group:- 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
3.2 Remove or replace broad cluster-admin bindings
Common problematic ones:- Bindings granting
cluster-adminto a wide group likesystem:mastersor to all authenticated users.
3.3 Create a minimal, explicit cluster-admin binding for your admin group
Create cluster-admin-oke-admins.yaml:oke-admins (mapped from your OCI IAM group via OKE auth) has full cluster-admin rights.4. Validate
- As an admin (in
oke-admins):
- As a non‑admin user (with a separate kubeconfig):
- 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.Using Python
Using Python
To restrict
3. Python Script: Audit and Remediate
This script:
Review the output and verify:
cluster-admin usage in an OCI OKE cluster using Python, you essentially need to:- Connect to the OKE cluster’s Kubernetes API.
- Enumerate all
ClusterRoleBindingobjects that referencecluster-admin. - Remove or tighten those bindings so only specific, approved subjects (users/groups/service accounts) retain
cluster-admin.
1. Prerequisites
-
Have kubectl access to the OKE cluster (so your kubeconfig works):
-
Install Python dependencies:
-
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, orServiceAccount - Namespaces (only for
ServiceAccount) - Names (e.g.,
oke-cluster-adminsgroup)
- Type:
3. Python Script: Audit and Remediate cluster-admin Bindings
This script:- Connects to the cluster using local kubeconfig.
- Lists all
ClusterRoleBindingobjects. - 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
5. OCI IAM Side (Optional But Recommended)
To fully align with the control:- Ensure OCI IAM groups mapped to cluster access do not automatically grant cluster-admin via
kubeconfiggeneration or admission policies. - Use more restrictive Kubernetes
ClusterRole/Rolebindings for regular dev/ops groups instead ofcluster-admin.
kubeconfig or admission-controller rules), I can provide a Python/OCI-SDK snippet for that side as well.Using Terraform
Using Terraform
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_v1resources and then narrow theirsubjectblocks, or - Remove them manually with
kubectl delete clusterrolebinding NAMEso only the controlled Terraform-managed binding remains.
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.
