-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
87 lines (71 loc) · 2.48 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
_ "embed"
"log"
"net/http"
_ "net/http/pprof"
"github.com/aiyengar2/helm-project-operator/pkg/controllers/common"
"github.com/aiyengar2/helm-project-operator/pkg/operator"
"github.com/aiyengar2/prometheus-federator/pkg/version"
command "github.com/rancher/wrangler-cli"
_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
_ "github.com/rancher/wrangler/pkg/generated/controllers/networking.k8s.io"
"github.com/rancher/wrangler/pkg/kubeconfig"
"github.com/spf13/cobra"
)
const (
HelmApiVersion = "monitoring.cattle.io/v1alpha1"
ReleaseName = "monitoring"
)
var (
SystemNamespaces = []string{"kube-system", "cattle-monitoring-system", "cattle-dashboards"}
//go:embed bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64
base64TgzChart string
debugConfig command.DebugConfig
)
type ProjectMonitoringValues struct {
}
type PrometheusFederator struct {
// Note: all Project Operator are expected to provide these RuntimeOptions
common.RuntimeOptions
Kubeconfig string `usage:"Kubeconfig file"`
}
func (f *PrometheusFederator) Run(cmd *cobra.Command, args []string) error {
go func() {
// required to set up healthz and pprof handlers
log.Println(http.ListenAndServe("localhost:80", nil))
}()
debugConfig.MustSetupDebug()
cfg := kubeconfig.GetNonInteractiveClientConfig(f.Kubeconfig)
ctx := cmd.Context()
if err := operator.Init(ctx, f.Namespace, cfg, common.Options{
// These fields are provided by the Project Operator
HelmApiVersion: HelmApiVersion,
ReleaseName: ReleaseName,
SystemNamespaces: SystemNamespaces,
ChartContent: base64TgzChart,
Singleton: true, // indicates only one HelmChart can be registered per project defined
// These fields are provided on runtime for all project operators
ProjectLabel: f.ProjectLabel,
SystemProjectLabelValue: f.SystemProjectLabelValue,
SystemDefaultRegistry: f.SystemDefaultRegistry,
CattleURL: f.CattleURL,
ClusterID: f.ClusterID,
NodeName: f.NodeName,
HelmJobImage: f.HelmJobImage,
AdminClusterRole: f.AdminClusterRole,
EditClusterRole: f.EditClusterRole,
ViewClusterRole: f.ViewClusterRole,
}); err != nil {
return err
}
<-cmd.Context().Done()
return nil
}
func main() {
cmd := command.Command(&PrometheusFederator{}, cobra.Command{
Version: version.FriendlyVersion(),
})
cmd = command.AddDebug(cmd, &debugConfig)
command.Main(cmd)
}