Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metrics handler #39

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down