Skip to content

Commit 1f25563

Browse files
authored
Merge pull request #32996 from my-git9/network-policies2
[zh] Update network-policies.md
2 parents 93c301a + 69984b9 commit 1f25563

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

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

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -121,42 +121,7 @@ An example NetworkPolicy might look like this:
121121

122122
下面是一个 NetworkPolicy 的示例:
123123

124-
```yaml
125-
apiVersion: networking.k8s.io/v1
126-
kind: NetworkPolicy
127-
metadata:
128-
name: test-network-policy
129-
namespace: default
130-
spec:
131-
podSelector:
132-
matchLabels:
133-
role: db
134-
policyTypes:
135-
- Ingress
136-
- Egress
137-
ingress:
138-
- from:
139-
- ipBlock:
140-
cidr: 172.17.0.0/16
141-
except:
142-
- 172.17.1.0/24
143-
- namespaceSelector:
144-
matchLabels:
145-
project: myproject
146-
- podSelector:
147-
matchLabels:
148-
role: frontend
149-
ports:
150-
- protocol: TCP
151-
port: 6379
152-
egress:
153-
- to:
154-
- ipBlock:
155-
cidr: 10.0.0.0/24
156-
ports:
157-
- protocol: TCP
158-
port: 5978
159-
```
124+
{{< codenew file="service/networking/networkpolicy.yaml" >}}
160125

161126
<!--
162127
POSTing this to the API server for your cluster will have no effect unless your chosen networking solution supports network policy.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: test-network-policy
5+
namespace: default
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
role: db
10+
policyTypes:
11+
- Ingress
12+
- Egress
13+
ingress:
14+
- from:
15+
- ipBlock:
16+
cidr: 172.17.0.0/16
17+
except:
18+
- 172.17.1.0/24
19+
- namespaceSelector:
20+
matchLabels:
21+
project: myproject
22+
- podSelector:
23+
matchLabels:
24+
role: frontend
25+
ports:
26+
- protocol: TCP
27+
port: 6379
28+
egress:
29+
- to:
30+
- ipBlock:
31+
cidr: 10.0.0.0/24
32+
ports:
33+
- protocol: TCP
34+
port: 5978
35+

0 commit comments

Comments
 (0)