Using the below definition for the last question of the ‘Practice Test Network Policies’ lab:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: internal-policy
namespace: default
spec:
podSelector:
matchLabels:
name: internal
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
name: mysql
ports:
- protocol: TCP
port: 3306
- to:
- podSelector:
matchLabels:
name: payroll
ports:
- protocol: TCP
port: 8080
I wasn’t able to contact the services from the internal pod.
The answer was marked as correct, but the answer from the solutions seems to be a bit different, is my way correct or not, I’m unsure now.