-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (39 loc) · 1.32 KB
/
main.go
File metadata and controls
48 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/runconduit/conduit/controller/telemetry"
log "github.com/sirupsen/logrus"
)
func main() {
addr := flag.String("addr", ":8087", "address to serve on")
metricsAddr := flag.String("metrics-addr", ":9997", "address to serve scrapable metrics on")
prometheusUrl := flag.String("prometheus-url", "http://127.0.0.1:9090", "prometheus url")
ignoredNamespaces := flag.String("ignore-namespaces", "", "comma separated list of namespaces to not list pods from")
kubeConfigPath := flag.String("kubeconfig", "", "path to kube config")
flag.Parse()
log.SetLevel(log.DebugLevel) // TODO: make configurable
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
server, lis, err := telemetry.NewServer(*addr, *prometheusUrl, strings.Split(*ignoredNamespaces, ","), *kubeConfigPath)
if err != nil {
log.Fatal(err.Error())
}
go func() {
log.Println("starting gRPC server on", *addr)
server.Serve(lis)
}()
go func() {
log.Info("serving scrapable metrics on", *metricsAddr)
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(*metricsAddr, nil)
}()
<-stop
log.Println("shutting down gRPC server on", *addr)
server.GracefulStop()
}