Skip to content

Commit

Permalink
feat(proxy): allow to configure the proxy bind address
Browse files Browse the repository at this point in the history
  • Loading branch information
jperville authored and paullaffitte committed Dec 27, 2023
1 parent 951055b commit 977dae1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

var (
kubeconfig string
proxyAddr string
metricsAddr string
rateLimitQPS int
rateLimitBurst int
Expand All @@ -33,6 +34,7 @@ func initFlags() {
if err := flag.Set("logtostderr", "true"); err != nil {
fmt.Fprint(os.Stderr, "could not enable logging to stderr")
}
flag.StringVar(&proxyAddr, "bind-address", ":8082", "The address the proxy registry endpoint binds to.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&kubeconfig, "kubeconfig", "", "Absolute path to the kubeconfig file")
flag.StringVar(&registry.Endpoint, "registry-endpoint", "kube-image-keeper-registry:5000", "The address of the registry where cached images are stored.")
Expand Down Expand Up @@ -88,5 +90,5 @@ func main() {
panic(fmt.Errorf("could not load root certificate authorities: %s", err))
}

<-proxy.New(k8sClient, metricsAddr, []string(insecureRegistries), rootCAs).Run()
<-proxy.New(k8sClient, metricsAddr, []string(insecureRegistries), rootCAs).Run(proxyAddr)
}
4 changes: 2 additions & 2 deletions internal/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ func (p *Proxy) Serve() *Proxy {
return p
}

func (p *Proxy) Run() chan struct{} {
func (p *Proxy) Run(proxyAddr string) chan struct{} {
p.Serve()
finished := make(chan struct{})
go func() {
if err := p.engine.Run(":8082"); err != nil {
if err := p.engine.Run(proxyAddr); err != nil {
panic(err)
}
finished <- struct{}{}
Expand Down

0 comments on commit 977dae1

Please sign in to comment.