More Info:
Clusters should be created with a network plugin that enforces NetworkPolicy. Without it, pod-to-pod traffic is unrestricted by default and a compromised pod can pivot freely across the cluster.Risk Level
HighAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
In OCI OKE, Kubernetes Network Policy enforcement must be enabled at cluster creation time; it cannot be switched on for an existing cluster.
So remediation in the Console means:
So remediation in the Console means:
-
Plan to replace the existing cluster
- Export current manifests:
- Take note of:
- Node shapes, OCPUs, memory
- VCN/subnets
- Load balancers, DNS, ingress
- Storage classes, PVCs, persistent volumes
- Plan downtime or a blue/green migration if needed.
- Export current manifests:
-
Create a new OKE cluster with Network Policy enabled (Console)
- In the OCI Console, go to:
Menu → Developer Services → Kubernetes Clusters (OKE) - Choose the compartment.
- Click Create cluster.
- Choose Quick Create or Custom Create (Custom gives more control).
- In the Networking or Cluster configuration section:
- Ensure Network type is VCN-native (required for network policies).
- Find the option Network policy or Kubernetes Network Policy and set it to Enabled.
- Select:
- Kubernetes version (use a supported, current version).
- VCN and subnets (reuse existing or create new).
- Worker node shape, OCPUs, and node count.
- Complete the wizard and click Create.
- Wait until the cluster status is Active and worker nodes are Ready.
- In the OCI Console, go to:
-
Point kubectl to the new cluster
- In the OKE cluster details page, click Access Cluster.
- Follow the instructions to:
- Install/ensure
kubectlandociCLI are set up. - Run the provided
oci ce cluster create-kubeconfig …command to get kubeconfig for the new cluster.
- Install/ensure
- Verify:
-
Recreate workloads on the new cluster
- Adjust the exported manifests if needed (storage classes, load balancer annotations, namespaces).
- Apply them to the new cluster:
- Recreate any external integrations (e.g., OCI Load Balancers, DNS records, external secrets) if they are not managed via manifests.
-
Define and test NetworkPolicies
- Create minimal NetworkPolicies first (e.g., allow-all within namespace) to avoid breaking traffic, then tighten:
- Apply and test app connectivity:
- Create minimal NetworkPolicies first (e.g., allow-all within namespace) to avoid breaking traffic, then tighten:
-
Cut over and decommission old cluster
- Update DNS / ingress / external endpoints to point to the new cluster’s load balancers.
- Validate workloads and traffic flows.
- When satisfied, in the Console:
- Go to Kubernetes Clusters (OKE).
- Select the old cluster.
- Drain & cordon nodes if you want a clean shutdown:
- Click Delete to remove the old cluster and node pools.
Using CLI
Using CLI
Below are the concrete OCI CLI steps to enable Network Policy on an OKE cluster.
If this returns
Open Do not remove any existing keys in
This will enable network policy support (Calico) on the cluster.
You should now see:
This completes the remediation using OCI CLI.
1. Prerequisites
- OCI CLI installed and configured (
oci setup config) - You have permission to manage the target OKE cluster
- You know the OCID of the cluster you want to update
2. Verify current Network Policy setting
false or null, Network Policy is not enabled.3. Get the full existing options payload
You must preserve the existing cluster options and only flip the network policy flag.options.json and locate/ensure this structure exists:- If
"kubernetes-network-config"exists, just set"is-network-policy-enabled": true. - If it doesn’t exist, add it under
options:
options.json.4. Update the cluster to enable Network Policy
5. Confirm Network Policy is enabled
6. (Kubernetes side) Start using NetworkPolicies
Once enabled on the cluster, apply KubernetesNetworkPolicy resources as usual:Using Python
Using Python
In OKE, Kubernetes Network Policy can only be enabled at cluster creation time. You cannot turn it on for an existing cluster; you must create a new OKE cluster with network policy support enabled, then migrate workloads.Below are the steps and an example using the OCI Python SDK.
Important notes:
Then create a simple If the policy works (pods lose connectivity as expected), network policy is enabled.
1. Prerequisites
- OCI Python SDK installed:
- A configured OCI profile in
~/.oci/config(or use instance principal / resource principal). - Existing:
- Compartment OCID
- VCN OCID
- Subnet OCIDs for worker nodes and pods (for VCN-native pod networking)
- KMS key etc. if you use encryption (optional)
2. Enable Network Policy on a New OKE Cluster (Python)
Network policy is enabled by:- Using VCN-native pod networking
- Setting the network policy flag in the cluster’s network configuration
oci.container_engine.models).- Field names like
is_network_policy_enabled,cni_type,pod_network_option_detailscan differ slightly depending on SDK release.- Run in Python REPL:
and confirm the exact property names for:
- CNI type / pod networking
- Network policy flag
- Run in Python REPL:
- If your SDK has a different model name for pod networking (e.g.,
ClusterPodNetworkOptionDetailsor similar), use that instead and set itsis_network_policy_enabledor equivalent.
3. Verify Network Policy Support in the New Cluster
After the cluster is active and node pools are created:NetworkPolicy and validate it is enforced:4. Migrate Workloads
- Deploy your workloads to the new cluster.
- Migrate services, ingresses, secrets, and PVCs as needed.
- Decommission the old cluster once migration is complete.
inspect.getsource for VcnIpNativePodNetworkOption / ClusterCreateOptions from your environment, I can give you an exact, version-accurate Python snippet.Using Terraform
Using Terraform
OCI_VCN_NATIVE); Terraform cannot switch an existing cluster’s CNI in place, so this change will destroy and recreate the oci_containerengine_cluster resource (cluster outage and node/pod replacement).After updating the Terraform, terraform plan should show the oci_containerengine_cluster resource being replaced with the cluster_pod_network_options[0].cni_type changing from its current value (for example "FLANNEL_OVERLAY") to "OCI_VCN_NATIVE".
