More Info:
The clusters CNI plugin should support Kubernetes NetworkPolicy enforcement (for example, OCI VCN-Native Pod Networking or Flannel with a policy-aware add-on). Without this support, NetworkPolicy resources are accepted but never enforced.Risk Level
MediumAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To have the OKE CNI plugin support Kubernetes NetworkPolicies, the cluster must be:
If you tell me your cluster’s current networking type (VCN-native vs Flannel) from the console, I can give a more exact “change vs recreate” path.
- Using VCN-native (OCI VCN CNI) networking, and
- Have Network Policy enabled at cluster creation time.
1. Check your current cluster networking mode
- In the OCI Console, go to: Developer Services → Kubernetes Clusters (OKE).
- Select your Cluster.
- On the Cluster Details page, check:
- Cluster Type / Networking:
- If it says VCN-native or similar: good.
- If it says Flannel or Overlay: you must create a new cluster; network policies aren’t supported on this CNI.
- Cluster Type / Networking:
1a. If cluster is already VCN-native: verify Network Policy add-on
For recent console versions, Network Policy is controlled via an add-on:- In your Cluster Details page, check the Add-ons or Add-ons Management tab (name may vary).
- Look for something like Network Policy or Kubernetes Network Policy:
- If it is Enabled / Installed, your CNI already supports NetworkPolicies. You just need to apply
NetworkPolicyobjects withkubectl. - If it is Disabled / Not installed and the UI allows toggling:
- Click Edit Add-ons (or similar).
- Enable the Network Policy add-on.
- Save/Apply and wait until the status is Active.
- If it is Enabled / Installed, your CNI already supports NetworkPolicies. You just need to apply
2. Create a new OKE cluster with CNI network policies enabled (OCI Console)
- In the OCI Console, go to Developer Services → Kubernetes Clusters (OKE).
- Click Create Cluster.
- Choose the Compartment.
- Select Quick Create or Custom Create:
- Custom Create gives explicit control; recommended.
2.1. Configure networking as VCN-native
-
In the Cluster Configuration step:
- Ensure Kubernetes version is a supported, recent version.
- Under Networking (or Network Type):
- Select VCN-native (or “Use existing VCN with native pod networking” / similar wording).
- Do not select Flannel/Overlay networking.
- Choose or create the VCN and subnets as prompted (node subnets and pod subnet if requested).
2.2. Enable Network Policy (CNI plugin support)
-
In the Add-ons or Optional Features section (typically later in the wizard):
- Locate Network Policy / Kubernetes Network Policy.
- Check/enable the Network Policy option.
- Confirm any related settings (there are typically no extra fields; it’s just On/Off).
-
Finish configuring:
- Configure Node Pools (shape, number of nodes, etc.).
- Click Create Cluster.
-
Wait for:
- Cluster status:
Active - Node Pools status:
Active - Add-ons: Network Policy shows
Active/Installed.
- Cluster status:
3. Migrate workloads from old cluster (if applicable)
- From your existing cluster:
- Export Kubernetes manifests (Deployments, Services, etc.) with
kubectl get ... -o yamlor from your Git/CI.
- Export Kubernetes manifests (Deployments, Services, etc.) with
- Point
kubectlto the new cluster (download kubeconfig from the cluster details page via Access Cluster). - Apply the manifests:
- Configure NetworkPolicy objects in the new cluster as needed.
- Update DNS, ingress, or external references to point to the new cluster; then decommission the old cluster when traffic has drained.
4. Validate NetworkPolicy support
- Create a simple NetworkPolicy in the new cluster (e.g., deny all ingress to a namespace):
- Apply it:
- Verify that traffic to pods in that namespace is blocked as expected from other pods/namespaces. If behavior enforces the policy, the OKE CNI Network Policy support is working.
If you tell me your cluster’s current networking type (VCN-native vs Flannel) from the console, I can give a more exact “change vs recreate” path.
Using CLI
Using CLI
In OKE, Kubernetes
Look for a structure under
Open Key rules:
Wait for the work request to complete:or get the last work request ID from the previous command’s output and:
Confirm that the network policy flag (e.g.,
These policies will now be enforced by the OKE CNI plugin.
If your generated JSON doesn’t show any network-policy-related field at all, your cluster/OCI CLI version may not yet expose that feature; in that case, upgrade the cluster to a supported version or recreate the cluster with the correct options, then repeat the steps above.
NetworkPolicy is enforced only when the OKE CNI plugin has network policy enabled on the cluster. That is controlled in the cluster’s options via the OCI CLI.Below is the minimal, practical way to do this via OCI CLI.1. Prerequisites
- OCI CLI configured with a user that can manage OKE clusters.
- The cluster is VCN-native (OCI VCN IP Native) or at least using an OKE CNI version that supports network policies.
- You know your:
- Compartment OCID
- Cluster OCID
- VCN subnets for pods/services if required
2. Inspect current cluster options (check if network policy is enabled)
options (or options.kubernetesNetworkConfig / options.networkConfig) related to network policy, for example:networkPolicyConfig.isNetworkPolicyEnabled- or
kubernetesNetworkConfig.networkPolicyConfig.isNetworkPolicyEnabled
false or missing, you need to update.3. Generate the JSON skeleton for a cluster update
This avoids guessing field names:cluster-update.json. Find the options section. Within it you should see or add the network policy part, for example (schema names may differ slightly per OKE version; align with what you saw in step 2):- Do not remove or change other existing fields you don’t intend to modify.
- Only set
"isNetworkPolicyEnabled": truewithin the appropriate network config section that already exists.
networkConfig or similar, mirror that exact structure and field name; the key is to set the isNetworkPolicyEnabled flag to true in the right place.4. Apply the update to enable network policy
5. Verify network policy support is enabled
Re-check the options:isNetworkPolicyEnabled) is now true.6. Use Kubernetes NetworkPolicy resources
Once enabled, you can apply standard KubernetesNetworkPolicy YAML:If your generated JSON doesn’t show any network-policy-related field at all, your cluster/OCI CLI version may not yet expose that feature; in that case, upgrade the cluster to a supported version or recreate the cluster with the correct options, then repeat the steps above.
Using Python
Using Python
For OKE, network policies are only supported when using the OCI VCN-Native CNI with network policy mode enabled. You cannot “flip a switch” on an existing non‑VCN‑native cluster; you must create (or already have) a cluster with the right CNI options.Below are step‑by‑step remediation instructions using Python and the OCI SDK.
Optionally, wait for the cluster to become
Apply with:
You should see:
If you provide your existing cluster’s details (network type and pod_network_options), I can tailor a Python migration script to mirror its settings while enabling
1. Prerequisites
-
Install/upgrade SDK:
-
Have a configured OCI CLI/profile (used by the SDK):
~/.oci/configwith a profile, e.g.[DEFAULT]. -
Collect:
compartment_idvcn_idkubernetes_versioncluster_name- Subnets for:
endpoint_subnet_id(API endpoint)service_lb_subnet_ids(Service LB subnets)
2. Understand the Required CNI Settings
For OKE to support Kubernetes NetworkPolicies with the OCI CNI, you need a cluster with:network_config→type = "VCN_NATIVE"options.kubernetes_network_config.pod_network_optionsincluding:cni_type = "OCI_VCN_IP_NATIVE"nsg_mode = "POLICY"(this turns on network-policy mode)
3. Create a New OKE Cluster with Network Policy–Capable CNI (Python)
ACTIVE:4. Create Node Pools for the New Cluster (Python)
5. Migrate Workloads from the Old Cluster
-
Get kubeconfig for the new cluster (can also be done with the Python SDK using
ce_client.create_kubeconfig): -
Use
kubectlto:- Export manifests from the old cluster (or use your IaC manifests/Helm charts).
- Apply them to the new cluster:
- Cut traffic over (e.g., update DNS / load balancer targets if necessary).
- Decommission the old cluster and its node pools once traffic is fully moved.
6. Apply Kubernetes NetworkPolicies
Now that your cluster uses the OCI VCN-native CNI inPOLICY mode, you can define NetworkPolicies as usual:7. Verifying CNI and Network Policy Support (Python snippet)
To confirm the cluster is using the correct CNI options:Network type: VCN_NATIVECNI type: OCI_VCN_IP_NATIVENSG mode: POLICY
If you provide your existing cluster’s details (network type and pod_network_options), I can tailor a Python migration script to mirror its settings while enabling
NSG_MODE=POLICY.Using Terraform
Using Terraform
cni_type = "OCI_VCN_IP_NATIVE" enables a CNI that enforces Kubernetes NetworkPolicy. Changing the CNI type on an existing OKE cluster forces replacement; terraform apply will destroy and recreate the cluster to apply this setting, causing an outage for workloads on that cluster.Verification: terraform plan should show options[0].cluster_pod_network_options[0].cni_type changing from its current value (for example "FLANNEL_OVERLAY" or null) to "OCI_VCN_IP_NATIVE", with the plan indicating that the oci_containerengine_cluster resource will be replaced.
