diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index a3c1fc2..04f3e3f 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -8,10 +8,17 @@ import ( "external-dns-openstack-webhook/internal/designate/provider" + "github.com/prometheus/client_golang/prometheus/promhttp" + "sigs.k8s.io/external-dns/endpoint" "sigs.k8s.io/external-dns/provider/webhook/api" ) +const ( + webhookServerAddr = "127.0.0.1:8888" + statusServerAddr = "0.0.0.0:8080" +) + func main() { log.SetLevel(log.DebugLevel) @@ -29,31 +36,31 @@ func main() { w.WriteHeader(http.StatusInternalServerError) } }) + m.HandleFunc("/metrics", promhttp.Handler().ServeHTTP) go func() { - log.Debug("Starting status server on :8080") + log.Debugf("Starting status server on %s", statusServerAddr) s := &http.Server{ - Addr: "0.0.0.0:8080", + Addr: statusServerAddr, Handler: m, } - l, err := net.Listen("tcp", "0.0.0.0:8080") + l, err := net.Listen("tcp", statusServerAddr) if err != nil { log.Fatal(err) } err = s.Serve(l) if err != nil { - log.Fatalf("health listener stopped : %s", err) + log.Fatalf("status listener stopped : %s", err) } }() - epf := endpoint.NewDomainFilter([]string{}) dp, err := provider.NewDesignateProvider(epf, false) if err != nil { log.Fatalf("NewDesignateProvider: %v", err) } - log.Printf("Starting server") - api.StartHTTPApi(dp, startedChan, 0, 0, "127.0.0.1:8888") + log.Debugf("Starting webhook server on %s", webhookServerAddr) + api.StartHTTPApi(dp, startedChan, 0, 0, webhookServerAddr) } diff --git a/go.mod b/go.mod index 8b892ec..73b456d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,10 @@ require ( sigs.k8s.io/external-dns v0.15.1 ) -require github.com/gophercloud/gophercloud/v2 v2.6.0 +require ( + github.com/gophercloud/gophercloud/v2 v2.6.0 + github.com/prometheus/client_golang v1.20.5 +) require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.46.3 // indirect @@ -20,11 +23,11 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/kr/text v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect diff --git a/go.sum b/go.sum index 12fa8a6..d5377ad 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=