forked from abahmed/kwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (39 loc) · 1.19 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
package main
import (
"fmt"
"github.com/abahmed/kwatch/alertmanager"
"github.com/abahmed/kwatch/client"
"github.com/abahmed/kwatch/config"
"github.com/abahmed/kwatch/constant"
"github.com/abahmed/kwatch/controller"
"github.com/abahmed/kwatch/pvcmonitor"
"github.com/abahmed/kwatch/upgrader"
"github.com/abahmed/kwatch/version"
"github.com/sirupsen/logrus"
)
func main() {
logrus.Infof(fmt.Sprintf(constant.WelcomeMsg, version.Short()))
config, err := config.LoadConfig()
if err != nil {
logrus.Fatalf("failed to load config: %s", err.Error())
}
// create kubernetes client
client := client.Create(&config.App)
alertManager := alertmanager.AlertManager{}
alertManager.Init(config.Alert, &config.App)
// send notification to providers
alertManager.Notify(fmt.Sprintf(constant.WelcomeMsg, version.Short()))
// check and notify if newer versions are available
upgrader := upgrader.NewUpgrader(&config.Upgrader, &alertManager)
go upgrader.CheckUpdates()
// start monitoring Persistent Volume Claims
pvcMonitor :=
pvcmonitor.NewPvcMonitor(client, &config.PvcMonitor, &alertManager)
go pvcMonitor.Start()
// start controller
controller.Start(
client,
&alertManager,
config,
)
}