Create a Network Policy
Set policies to allow or deny network traffic between Pods.
Prerequisites
- The cluster must have a CNI plugin that supports Network Policy (e.g., Calico, Cilium).
- Note the labels of the Pods to which the policy will apply.
INFO
Without a Network Policy, all traffic between Pods is allowed. Once any policy is applied, only explicitly permitted traffic passes through.
Step 1. Open the Create Network Policy form
Select Policy → Network policies from the left sidebar. Click the Create network policy button in the top right.
Step 2. Enter basic information
| Field | Description | Example |
|---|---|---|
| Name | Network Policy name | allow-frontend-to-backend |
| Namespace | Target namespace | default |
Step 3. Configure Pod Selector
Select the Pods this policy applies to using labels.
| Key | Value |
|---|---|
app | backend |
Leave blank to apply to all Pods in the namespace.
Step 4. Configure Ingress (inbound) rules
Define what incoming traffic this Pod can receive.
Click Add Ingress Rule.
Configure From (allowed sources)
| Source Type | Description | Example |
|---|---|---|
| Pod Selector | Allow only from Pods with specific labels | app: frontend |
| Namespace Selector | Allow only from Pods in specific namespaces | team: platform |
| IP Block | Allow only from specific CIDR ranges | 10.0.0.0/24 |
Configure Ports (allowed ports)
| Field | Description | Example |
|---|---|---|
| Protocol | TCP or UDP | TCP |
| Port | Allowed port number | 8080 |
Step 5. Configure Egress (outbound) rules
To restrict outgoing traffic from Pods, click Add Egress Rule.
Specify the allowed destinations in the To section. If no Egress rules are set, all outbound traffic is allowed.
Step 6. Confirm creation
Click Create. Verify the created policy in the Network policies list.
The policy takes effect immediately on the selected Pods.