Skip to content

Commit d62e46d

Browse files
committed
Make multiport egress policy a standalone YAML
1 parent 2ece88e commit d62e46d

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

content/en/docs/concepts/services-networking/network-policies.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,7 @@ When writing a NetworkPolicy, you can target a range of ports instead of a singl
206206

207207
This is achievable with the usage of the `endPort` field, as the following example:
208208

209-
```yaml
210-
apiVersion: networking.k8s.io/v1
211-
kind: NetworkPolicy
212-
metadata:
213-
name: multi-port-egress
214-
namespace: default
215-
spec:
216-
podSelector:
217-
matchLabels:
218-
role: db
219-
policyTypes:
220-
- Egress
221-
egress:
222-
- to:
223-
- ipBlock:
224-
cidr: 10.0.0.0/24
225-
ports:
226-
- protocol: TCP
227-
port: 32000
228-
endPort: 32768
229-
```
209+
{{< codenew file="service/networking/networkpolicy-multiport-egress.yaml" >}}
230210

231211
The above rule allows any Pod with label `role=db` on the namespace `default` to communicate
232212
with any IP within the range `10.0.0.0/24` over TCP, provided that the target

content/en/examples/examples_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ func TestExampleObjectSchemas(t *testing.T) {
675675
"name-virtual-host-ingress-no-third-host": {&networking.Ingress{}},
676676
"namespaced-params": {&networking.IngressClass{}},
677677
"networkpolicy": {&networking.NetworkPolicy{}},
678+
"networkpolicy-multiport-egress": {&networking.NetworkPolicy{}},
678679
"network-policy-allow-all-egress": {&networking.NetworkPolicy{}},
679680
"network-policy-allow-all-ingress": {&networking.NetworkPolicy{}},
680681
"network-policy-default-deny-egress": {&networking.NetworkPolicy{}},
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: multi-port-egress
5+
namespace: default
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
role: db
10+
policyTypes:
11+
- Egress
12+
egress:
13+
- to:
14+
- ipBlock:
15+
cidr: 10.0.0.0/24
16+
ports:
17+
- protocol: TCP
18+
port: 32000
19+
endPort: 32768
20+

0 commit comments

Comments
 (0)