Skip to content

Commit

Permalink
add flag to poenable rt forward ting of he loadbalancer ports
Browse files Browse the repository at this point in the history
Change-Id: Ide7ec2da641da3ec0f7c51413a692c356d65bf56
  • Loading branch information
aojea committed Sep 2, 2024
1 parent f6b64c8 commit 7a321a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ import (
)

var (
flagV int
enableLogDump bool
logDumpDir string
flagV int
enableLogDump bool
logDumpDir string
enableLBPortMapping bool
)

func init() {
flag.IntVar(&flagV, "v", 2, "Verbosity level")
flag.BoolVar(&enableLogDump, "enable-log-dumping", false, "store logs to a temporal directory or to the directory specified using the logs-dir flag")
flag.StringVar(&logDumpDir, "logs-dir", "", "store logs to the specified directory")
flag.BoolVar(&enableLBPortMapping, "enable-lb-port-mapping", false, "enable port-mapping on the load balancer ports")

flag.Usage = func() {
fmt.Fprint(os.Stderr, "Usage: cloud-provider-kind [options]\n\n")
Expand Down Expand Up @@ -106,6 +108,11 @@ func Main() {
config.DefaultConfig.LoadBalancerConnectivity = config.Tunnel
}

// flag overrides autodetection
if enableLBPortMapping {
config.DefaultConfig.LoadBalancerConnectivity = config.Portmap
}

// default control plane connectivity to portmap, it will be
// overriden if the first cluster added detects direct
// connecitivity
Expand Down
3 changes: 2 additions & 1 deletion pkg/loadbalancer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ func (s *Server) createLoadBalancer(clusterName string, service *v1.Service, ima
}...)
}

if s.tunnelManager != nil {
if s.tunnelManager != nil ||
config.DefaultConfig.LoadBalancerConnectivity == config.Portmap {
// Forward the Service Ports to the host so they are accessible on Mac and Windows
for _, port := range service.Spec.Ports {
if port.Protocol != v1.ProtocolTCP && port.Protocol != v1.ProtocolUDP {
Expand Down

0 comments on commit 7a321a4

Please sign in to comment.