K8s Network policy endPort can not be applied

11/1/2021

I'm trying to apply egress port range for my k8s network policy like this:

 egress:
  - to:
    - ipBlock:
        cidr: 10.0.0.0/24
    ports:
    - protocol: TCP
      port: 32000
      endPort: 32768

Starting fine but when I describe that, I only see that port 32000 is allowed. Do I miss something? Or have I made some mistake?

Thanks.

-- duy nguyễn
kubernetes
kubernetes-networkpolicy

1 Answer

11/2/2021

It seems you took this example from Targeting a range of Ports. Here are 2 questions:

  1. I see endPort works only with NetworkPolicyEndPort enabled feature. Despite the fact it is states, this feature enabled by default, can you please check if it turned for you? enter image description here
  1. Whats your CNI plugin and does it support endPort in NetworkPolicy spec?

enter image description here

-- Vit
Source: StackOverflow