Skip to content

Commit

Permalink
fix: Make sure CDS server is reachable with API server port-forward
Browse files Browse the repository at this point in the history
  • Loading branch information
rg0now committed Jan 25, 2024
1 parent ff7081a commit 4228d94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/go-logr/logr v1.4.1
github.com/go-logr/zapr v1.3.0
github.com/l7mp/stunner v0.17.3
github.com/l7mp/stunner v0.17.4
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.30.0
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/l7mp/stunner v0.17.3 h1:mPMiiPgIB2WSPdLG7kO2igBzI5F+A/EG72SEYKLwqYM=
github.com/l7mp/stunner v0.17.3/go.mod h1:BFz8i3IGwgfaQm2tm1K4h+uaNtKbluz3McbdYVUA73U=
github.com/l7mp/stunner v0.17.4 h1:hy8qH8H1/qIY875i2johkksFBflhszxGT7eoyt3vHhc=
github.com/l7mp/stunner v0.17.4/go.mod h1:aRBLtWGkzVuqZ1WsHEQ9hYL0DNp8drH9mGqA6HpJMZM=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
18 changes: 2 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"flag"
"fmt"
"os"
"strings"
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -113,21 +112,8 @@ func main() {
config.DataplaneMode = config.NewDataplaneMode(dataplaneMode)
setupLog.Info("dataplane mode", "mode", config.DataplaneMode.String())

if cdsAddr == stnrv1.DefaultConfigDiscoveryAddress {
// CDS address not overrridden on the command line: use env var
envAddr, ok := os.LookupEnv(envVarAddress)
if ok {
cdsAddr = envAddr
}
// add the default port
as := strings.Split(cdsAddr, ":")
if len(as) == 1 || (len(as) == 2 && as[1] == "") {
dd := strings.Split(stnrv1.DefaultConfigDiscoveryAddress, ":")
cdsAddr = fmt.Sprintf("%s:%s", cdsAddr, dd[1])
}
}
config.ConfigDiscoveryAddress = cdsAddr
setupLog.Info("config discovery server", "addr", config.ConfigDiscoveryAddress)
setupLog.Info("config discovery server", "addr", cdsAddr)

if d, err := time.ParseDuration(throttleTimeout); err != nil {
setupLog.Info("setting rate-limiting (throttle timeout)", "timeout", throttleTimeout)
Expand Down Expand Up @@ -172,7 +158,7 @@ func main() {
})

setupLog.Info("setting up CDS server", "address", cdsAddr)
c := config.NewCDSServer(config.ConfigDiscoveryAddress, logger)
c := config.NewCDSServer(cdsAddr, logger)

setupLog.Info("setting up operator")
op := operator.NewOperator(operator.OperatorConfig{
Expand Down

0 comments on commit 4228d94

Please sign in to comment.