The platform now provides two different UIs for Network Policies. The old one is maintained for compatibility reasons, while the new one is more flexible and provides a native YAML editor. We recommend using the new version.
Please contact the platform administrator to enable the network-policy-next
feature gate to access the new UI.
NetworkPolicy is a namespace-scoped Kubernetes resource and implemented by CNI plugins. Through network policies, you can control network traffic of Pods, achieving network isolation and reducing the risk of attacks.
By default, all Pods can communicate freely, allowing ingress and egress traffic from any source. When a NetworkPolicy is applied, the targeted Pods will only accept traffic that matches the spec.
Network policies only apply to container traffic. They don’t affect Pods running in hostNetwork mode.
Example NetworkPolicy:
from
and 'to' peer support namespaceSelector
, podSelector
, 'ipBlock'Enter Container Platform.
In the left navigation bar, click Network > Network Policies.
Click Create Network Policy.
Refer to the following instructions to complete the relevant configuration.
Area | Parameter | Description | |
---|---|---|---|
Target Pod | Pod Selector | Enter the labels of the target Pods in key-value form; if not set, it will apply to all Pods in the current namespace. | |
Preview of Target Pods Affected by Current Policy | Click Preview to see the target Pods affected by this network policy. | ||
Ingress | Block all ingress traffic | Block all ingress traffic to the target Pod. Note:
| |
Rules Description: If multiple sources are added in the rules, there is a logical OR relationship between them. | Pods in Current Namespace | Match Pods with specified labels in the current namespace; only matched Pods can access the target Pod. You can click Preview to see the Pods affected by the current rule. If this item is not configured, all Pods in the current namespace are allowed to access the target Pod by default. | |
Pods in Current Cluster | Match namespaces or Pods with specified labels in the cluster; only matched Pods can access the target Pod. You can click Preview to see the Pods affected by the current rule.
| ||
IP Range | Enter the CIDR that can access the target Pod and can exclude CIDR ranges that are not allowed to access the target Pod. If this item is not configured, any traffic can access the target Pod. Description: You can add exclusion items in the form of exampleip/32 to exclude a single IP address. | ||
Port | Match traffic on specified protocols and ports; numeric ports or port names on Pods can be added. If this item is not configured, all ports will be matched. | ||
Egress | Block all egress traffic | Block all egress traffic to the target Pod. Note:
| |
Other Parameters | Similar to the Ingress parameters, this will not be elaborated on here. |
If you want more details, check out the official docs on Network Policies.