Hi, I’m very new to K8s and I used the sample from the documentations page Network Policies which did not work after I had cut it down to my requirements. I changed it according to the tutor guide and it worked and created the Network Policy. I don’t understand why?
Cut down version from documentation that didn’t work:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ingress-to-nptest
namespace: default
spec:
podSelector:
matchLabels:
run: np-test-1
policyTypes:
- Ingress
ingress:
ports:
- protocol: TCP
port: 80
and the tutor guided one that worked:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ingress-to-nptest
namespace: default
spec:
podSelector:
matchLabels:
run: np-test-1
policyTypes:
- Ingress
ingress:
- ports:
- port: 80
protocol: TCP