-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
46 lines (39 loc) · 1.15 KB
/
main.go
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
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/version"
"k8s.io/klog/v2"
"net/http"
"topokube/factories"
"topokube/handlers"
"topokube/internal/namespaces"
"topokube/internal/pods"
)
func main() {
clientGoFactory := factories.ClientGoFactory{}
client := clientGoFactory.New()
registry := prometheus.NewRegistry()
registry.MustRegister(version.NewCollector("koozie"))
namespaceService := namespaces.NamespaceService{
Client: client,
}
podService := pods.PodService{
Client: client,
}
http.Handle("/health", handlers.HealthHandler{})
http.Handle(
"/metrics",
promhttp.HandlerFor(prometheus.Gatherers{registry}, promhttp.HandlerOpts{Registry: registry}))
http.Handle("/api", handlers.NamespaceHander{
Service: namespaceService,
})
http.Handle("/api/pods/", handlers.PodsHandler{
Service: podService,
})
http.Handle("/api/kubernetes-webhook", handlers.NewKubernetesWebhookHandler(registry))
err := http.ListenAndServeTLS(":8443", "/certificates/tls.crt", "/certificates/tls.key", nil)
if err != nil {
klog.Error(err)
}
}