# This succeeds because the NetworkPolicy contains and enables egress and ingress rules, and targets the pod's label. apiVersion: v1 kind: Pod metadata: name: test-pod labels: security: medium spec: containers: - name: nginx image: nginx ports: - containerPort: 80 --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: test spec: podSelector: matchLabels: security: medium policyTypes: - Egress - Ingress ingress: - from: - ipBlock: cidr: 0.0.0.0/0 ports: - protocol: TCP port: 8080 egress: - to: - podSelector: matchLabels: # Allow outbound with other medium-security pods. security: medium ports: - protocol: TCP port: 80