Network Policy Reference
The Network page of an environment holds two lists:
- its network policies, the rules on what may come in, and what may go out;
- its private links to remote networks.
Each policy and each link is deployed on its own, from its own page. This page covers the network policies. Private links have a page of their own.
Several policies per environment
An environment carries as many network policies as it needs. Each one has:
| Part | What it is |
|---|---|
| Name | Lowercase letters, digits and dashes; unique in the environment |
| Applies to | The workloads it concerns, chosen by label. Empty: every workload of the environment |
| Ingress Rules and Egress Rules | What it allows in, and out |
Create one with New policy, name it, then set what it applies to and write its rules on its page. A policy is removed from the list, or with Delete on its page: its rules are lifted at once.
Policies add up: traffic is allowed as soon as one policy that applies to the workload allows it. Use several to keep unrelated rules apart (one for the database tier, one for what partners may reach) so that changing one never redeploys the other.
An environment set up when it had a single policy shows it in the list like the others, with a notice on its page. Move the policy gives it a deployment of its own; its rules are lifted until you deploy it again.
Rationale: Why restrict traffic inside an environment.
Ingress and egress rules
Rules come in two lists, each a tab of the policy's page:
| List | What its rules describe |
|---|---|
| Ingress Rules | Traffic coming into the environment: who may call what runs in it |
| Egress Rules | Traffic going out of the environment: what it may call |
Defining a rule with peers and ports
A rule names who is on the other side, and on which ports.
Who. One or several of:
| Choice | What it means |
|---|---|
| Any source/destination | Everyone |
| Pods matching labels | Workloads of the environment that carry the labels you give |
| All pods in matching namespaces | Everything in the namespaces that carry the labels you give |
| Pods in matching namespaces with matching labels | Both conditions at once |
| External IP range | A range of addresses, such as 203.0.113.0/24, with exceptions if needed |
Labels are written key=value, separated by commas.
Ports: each with its protocol, TCP, UDP or SCTP. Leave the ports empty for every port.
Preset rules
A rule can start from a preset. DNS — kube-dns lets the environment resolve names: UDP and TCP on port 53, to the name service of the cluster. Add it to the egress rules of an environment whose outgoing traffic you restrict, or its workloads will not find the services they call.
Addresses of workloads change at every restart. Rules that select workloads by labels keep working; rules on internal IP ranges do not.
Apply the Policies
A policy takes effect when you click Deploy changes on its page. That deploys this policy alone: nothing else of the environment is touched, and Apply on the environment does not deploy it. A policy only holds configuration: it has no running part of its own to watch.
Behavior and limits
- Rules are about the network. To decide who may call an API, and with which credentials, use policies on the gateway.
- A remote network reached through a private link is declared on the link, not in these rules.