728x90

docs : https://kubernetes.io/docs/concepts/services-networking/network-policies/

 

Network Policies

If you want to control traffic flow at the IP address or port level (OSI layer 3 or 4), NetworkPolicies allow you to specify rules for traffic flow within your cluster, and also between Pods and the outside world. Your cluster must use a network plugin tha

kubernetes.io

#k run curl --image=alpine/curl --rm -it --sh

#networkpolicy.yaml
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


k apply -f networkpolicy.yaml
728x90

+ Recent posts