More Info:
The Kubernetes API endpoint should be reachable only from approved networks (VCN CIDRs, bastions, or specific NSG members). Open control-plane endpoints are a primary target for credential and token abuse.Risk Level
CriticalAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Here’s how to restrict access to the OKE Kubernetes API (control plane) using the OCI Console.There are two main ways:
For existing clusters, you may need to update or recreate depending on your OKE version and options available.
If you share whether your current OKE endpoint is public or private, I can give a concrete, minimal rule set to apply for your case.
- Restrict a public endpoint with an IP allow-list
- Use a private endpoint (accessible only from your VCN)
1. Check current endpoint type and access
- Sign in to the OCI Console.
- Open the navigation menu → Developer Services → Kubernetes Clusters (OKE).
- Select your compartment, then click the cluster.
- On the Cluster details page, under Endpoint, note:
- Endpoint Type: Public or Private
- For Public: check configured Authorized IPs (CIDR list)
2. If you must keep a Public endpoint – restrict by IP
Use this if you still want internet access, but locked to specific IPs (e.g., office VPN, bastion).- In the Cluster details page, click Edit on the Endpoint Configuration section (name may appear as “Kubernetes API Endpoint” or similar).
- Ensure Endpoint Type is Public.
- In Authorized IPs (or “API Endpoint CIDR allowlist”):
- Remove
0.0.0.0/0or any broad networks you don’t intend to allow. - Add only the required source IPs/CIDRs, e.g.:
- Your corporate public IP:
203.0.113.10/32 - VPN egress subnet:
198.51.100.0/24
- Your corporate public IP:
- Remove
- Save/Update the configuration.
- Test from:
- An allowed IP:
kubectl get nodesshould work. - A disallowed IP: connection to the API should fail.
- An allowed IP:
3. Prefer a Private endpoint – restrict to your VCN
This is the most secure: the API is reachable only inside your VCN (via VCN, VPN, FastConnect, or bastion).3.1 Convert/ensure cluster is using a private endpoint
For new clusters, you can select Private API endpoint during creation.For existing clusters, you may need to update or recreate depending on your OKE version and options available.
- In Kubernetes Clusters (OKE) → your cluster → Cluster details.
- Look for Edit cluster / Edit endpoint configuration.
- If the console allows:
- Change Endpoint Type to Private.
- Select the VCN, subnet where the endpoint will be hosted.
- Confirm and save.
- If you cannot change endpoint type (option is disabled):
- Plan to create a new cluster with a Private endpoint and migrate workloads.
3.2 Lock down network access to the private endpoint
The private endpoint lives in a subnet; access is controlled by:- Network Security Groups (NSGs) attached to the OKE API endpoint
- Or Security Lists on the subnet
- In the Console, go to Networking → Virtual Cloud Networks.
- Open the VCN used by your OKE cluster.
- Go to Network Security Groups and locate the NSG associated with the Kubernetes API endpoint (name often includes the cluster name and “cp”/“api”).
- Edit the Ingress Rules:
- Remove any rule with source
0.0.0.0/0or overly broad CIDRs. - Add rules that allow TCP 6443 (Kubernetes API) only from:
- Your admin/bastion subnet CIDR (e.g.,
10.0.10.0/24), or - A specific host subnet or NSG.
- Your admin/bastion subnet CIDR (e.g.,
- Remove any rule with source
- If instead security lists are used:
- In the VCN, open Subnets → endpoint subnet.
- Edit the Security List:
- Restrict inbound rule for port 6443 to only the required internal CIDRs.
4. Ensure access path for admins and automation
After restricting:- If using private endpoint:
- Use a bastion host inside the VCN, or
- Use OCI Bastion service, or
- Connect over VPN / FastConnect so your admin machine is in an allowed CIDR.
- Update any CI/CD runners to come from the allowed CIDRs/subnets.
5. Verify restriction
- From an allowed network:
- Download kubeconfig from the Console (cluster page → Access Cluster → Local access / Cloud Shell, etc.).
- Run:
kubectl get namespaces– should succeed.
- From a disallowed IP/subnet:
- Kubernetes API calls should time out or be refused.
If you share whether your current OKE endpoint is public or private, I can give a concrete, minimal rule set to apply for your case.
Using CLI
Using CLI
Below are two common remediations for “OCI OKE access to Kubernetes control plane should be restricted” using OCI CLI:
Look for:
Add rules to only allow your trusted sources to port 6443:Wait for the work request to finish:Confirm:
Again, check state and config:Ensure:
3. Validate
After any change, from your allowed location:Then:If you need, tell me whether your cluster is currently public or private and I can give the exact JSON payload for your case.
- A) Restrict a public OKE endpoint to specific IPs
- B) Switch to a private OKE endpoint (or ensure it’s private and protected via NSGs)
0. Prerequisites
Make sure:ociCLI is installed and configured (oci setup configdone).- You know your:
cluster-id- Compartment OCID
- Subnet OCID for the control plane endpoint
- NSG OCIDs (recommended for additional restriction)
1. Get current cluster configuration
isPublicIpEnabledsubnetIdnsgIdspublicEndpointConfig.allowedPublicIpAddresses
isPublicIpEnabled = true and allowedPublicIpAddresses is null or contains 0.0.0.0/0, it’s effectively open.A) Restrict a Public OKE Control Plane Endpoint
1. Decide allowed IP CIDRs
Example: only allow your corporate public IP and a jump host:2. (Recommended) Create / identify NSGs
Create an NSG for the OKE control plane subnet if you don’t have one:3. Update the OKE cluster endpoint config (restrict IPs)
B) Use a Private OKE Control Plane Endpoint
This limits access to VCN/internal networks and NSGs.1. Ensure you have a private subnet for control plane
- Subnet should be private (no internet gateway route).
- Attach a suitable NSG.
2. Update cluster to use private endpoint
isPublicIpEnabledisfalse- NSGs are in place and only allow required internal sources on port 6443.
3. Validate kubectl Access
After any change, from your allowed location:Using Python
Using Python
To restrict access to the Kubernetes control plane in OCI OKE, you generally want to:
- Disable the public API endpoint for the cluster (make the control plane private), or
- At minimum, ensure the API endpoint is only reachable from controlled private subnets/NSGs.
1. Prerequisites
ociSDK installed:- A valid OCI config file (e.g.
~/.oci/config) and a profile with permissions to update OKE clusters:OCI CLI-style credentials, or instance principal/session auth if you prefer (code can be adapted).
2. High‑level steps
- Identify the OKE cluster OCID.
- Decide:
- Which private subnet will host the control plane endpoint.
- Which Network Security Groups (NSGs) will control traffic to that subnet.
- Update the OKE cluster’s endpoint configuration to:
- Disable public IP access (
is_public_ip_enabled=False). - Point to the correct private subnet and NSGs.
- Disable public IP access (
3. Python example: Make control plane private and restrict via NSGs
4. NSG rules (conceptual)
On the NSGs you pass inCONTROL_PLANE_NSG_IDS, ensure rules:- Ingress:
- Allow TCP 6443 (Kubernetes API) and any other required ports
- Source: only:
- Bastion hosts
- Admin subnets
- CI/CD runners
- On‑prem IPs via VPN/DRG
- No
0.0.0.0/0or broad public CIDRs.
- Source:
10.0.10.0/24(bastion subnet) - Protocol: TCP
- Port: 6443
5. Notes / edge cases
- If the cluster was created as public endpoint only in some older setups, you might need to:
- Ensure a private subnet exists with route to your workers/bastion; then
- Apply the
UpdateClusterEndpointConfigDetailsas shown.
- After making the endpoint private, your
kubectlclients must reach that private subnet (via VPN, FastConnect, bastion, etc.).
Using Terraform
Using Terraform
oci_containerengine_cluster endpoint configuration; worker nodes and node pools are not recreated, but expect a short control-plane reconfiguration period.Verification: terraform plan should show an in-place update to oci_containerengine_cluster.OKE_CLUSTER changing endpoint_config.is_public_ip_enabled from true to false, plus creation of the oci_core_network_security_group and oci_core_network_security_group_security_rule resources (and the API subnet if it is new).
