81 lines
1.2 KiB
Markdown
81 lines
1.2 KiB
Markdown
|
**mysql-redis-nw.yaml**
|
|||
|
|
|||
|
```
|
|||
|
apiVersion: networking.k8s.io/v1
|
|||
|
kind: NetworkPolicy
|
|||
|
metadata:
|
|||
|
name: mysql-np
|
|||
|
namespace: nw-demo
|
|||
|
spec:
|
|||
|
podSelector:
|
|||
|
matchLabels:
|
|||
|
app: mysql
|
|||
|
policyTypes:
|
|||
|
- Ingress
|
|||
|
ingress:
|
|||
|
- from:
|
|||
|
- namespaceSelector:
|
|||
|
matchLabels:
|
|||
|
access-nw-mysql-redis: "true"
|
|||
|
ports:
|
|||
|
- protocol: TCP
|
|||
|
port: 3306
|
|||
|
---
|
|||
|
apiVersion: networking.k8s.io/v1
|
|||
|
kind: NetworkPolicy
|
|||
|
metadata:
|
|||
|
name: redis-np
|
|||
|
namespace: nw-demo
|
|||
|
spec:
|
|||
|
podSelector:
|
|||
|
matchLabels:
|
|||
|
app: redis
|
|||
|
policyTypes:
|
|||
|
- Ingress
|
|||
|
ingress:
|
|||
|
- from:
|
|||
|
- namespaceSelector:
|
|||
|
matchLabels:
|
|||
|
access-nw-mysql-redis: "true"
|
|||
|
ports:
|
|||
|
- protocol: TCP
|
|||
|
port: 6379
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
**nginx-nw.yaml**
|
|||
|
|
|||
|
```
|
|||
|
apiVersion: networking.k8s.io/v1
|
|||
|
kind: NetworkPolicy
|
|||
|
metadata:
|
|||
|
name: nginx-np
|
|||
|
namespace: nw-demo
|
|||
|
spec:
|
|||
|
podSelector:
|
|||
|
matchLabels:
|
|||
|
app: nginx
|
|||
|
policyTypes:
|
|||
|
- Ingress
|
|||
|
ingress:
|
|||
|
- from:
|
|||
|
- namespaceSelector:
|
|||
|
matchLabels:
|
|||
|
app.kubernetes.io/name: ingress-nginx
|
|||
|
podSelector:
|
|||
|
matchLabels:
|
|||
|
"app.kubernetes.io/name": ingress-nginx
|
|||
|
- podSelector: {}
|
|||
|
ports:
|
|||
|
- protocol: TCP
|
|||
|
port: 80
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|