Skip to content

Commit

Permalink
service: use protocol ANY when not differentiating TCP and UDP
Browse files Browse the repository at this point in the history
Signed-off-by: Gilberto Bertin <[email protected]>
  • Loading branch information
jibi authored and dhij committed Sep 18, 2024
1 parent 256a696 commit 752bf47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/k8s/watchers/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,12 +940,12 @@ func stripServiceProtocol(svc *k8s.Service) *k8s.Service {
svc = svc.DeepCopy()

for _, port := range svc.Ports {
port.Protocol = "NONE"
port.Protocol = "ANY"
}

for _, nodePort := range svc.NodePorts {
for _, port := range nodePort {
port.Protocol = "NONE"
port.Protocol = "ANY"
}
}

Expand All @@ -957,7 +957,7 @@ func stripEndpointsProtocol(endpoints *k8s.Endpoints) *k8s.Endpoints {

for _, backend := range endpoints.Backends {
for _, port := range backend.Ports {
port.Protocol = "NONE"
port.Protocol = "ANY"
}
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ func (s ServiceFlags) UInt16() uint16 {
const (
// NONE type.
NONE = L4Type("NONE")
// ANY type.
ANY = L4Type("ANY")
// TCP type.
TCP = L4Type("TCP")
// UDP type.
Expand Down Expand Up @@ -529,6 +531,8 @@ func NewL4Type(name string) (L4Type, error) {
switch strings.ToLower(name) {
case "none":
return NONE, nil
case "any":
return ANY, nil
case "tcp":
return TCP, nil
case "udp":
Expand All @@ -549,7 +553,7 @@ func NewL4TypeFromNumber(proto uint8) L4Type {
case 132:
return SCTP
default:
return NONE
return ANY
}
}

Expand Down

0 comments on commit 752bf47

Please sign in to comment.