I have a pod called mysql-1 with ports 3306 and 3307 open.
I want to create a network policy that allow ingress connection from backend-1 to 3306 and backend-2 to 3307.
Right now all I could come up with is this policy:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: mysql-ingress-policy-1
namespace: v2ci
spec:
podSelector:
matchLabels:
app: mysql-1
release: v2
types:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: backend-1
release: v2
- podSelector:
matchLabels:
app: backend-1
release: v2
ports:
- protocol: TCP
port: 3306
- protocol: TCP
port: 3307
The problem is that with this policy each backend pod has access to both ports.
Is it possible to combine ports
with podSelector
somehow or should I just create one network policy for each backend pod?