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 d-honeybadger committed Jan 23, 2025
1 parent 9602462 commit 713636b
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/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,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 @@ -452,7 +452,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 @@ -530,6 +532,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 @@ -550,7 +554,7 @@ func NewL4TypeFromNumber(proto uint8) L4Type {
case 132:
return SCTP
default:
return NONE
return ANY
}
}

Expand Down

0 comments on commit 713636b

Please sign in to comment.