projectcalico / calico

Cloud native networking and network security
https://docs.tigera.io/calico/latest/about/
Apache License 2.0
5.85k stars 1.31k forks source link

HostEndpoint node selector + interface name regexp #8840

Open jonas-jasas opened 3 months ago

jonas-jasas commented 3 months ago

Feature request

To reduce HostEndpoint resource count in case of multiple node scenario, would be great to have HostEndpoint node selector (based on k8s labels) and interface name match using regexp.

caseydavenport commented 2 months ago

@jonas-jasas could you provide some more details about what you are looking for here?

JonasJasas commented 2 months ago

Each node has 4 network interfaces, so I have to create 40 HostEndpoint resources instead of 4.

caseydavenport commented 2 months ago

Have you considered Calico's auto host endpoint feature? https://docs.tigera.io/calico/latest/network-policy/hosts/kubernetes-nodes#automatic-host-endpoints

Calico can create a single host endpoint per-node that represents all interfaces on the node.

JonasJasas commented 2 months ago

Is it possible to classify which interface is external which internal using auto host endpoint feature? In my case I do this:

apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
  name: stag-hw1-eth1
  labels:
    role: worker-ext
spec:
  interfaceName: eth1
  node: stag-hw1

---

apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
  name: stag-hw1-eth3
  labels:
    role: worker-ext
spec:
  interfaceName: eth3
  node: stag-hw1

---

apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
  name: stag-hw2-eth1
  labels:
    role: worker-ext
spec:
  interfaceName: eth1
  node: stag-hw2

---

apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
  name: stag-hw2-eth3
  labels:
    role: worker-ext
spec:
  interfaceName: eth3
  node: stag-hw2
caseydavenport commented 2 months ago

Ah right. No, if you want to be able to treat different interfaces on the same node differently, then today you would need to create HEPs for each.

I think it would be a nice enhancement if we did what you originally suggested, then - a node selector and regex matching on interfaces.