-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
61 lines (50 loc) · 1.9 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
//go:generate go run github.com/rakyll/statik -src=./manifests -dest ./pkg -p manifests -f
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"k8s.io/klog"
"github.com/projectsyn/steward/pkg/agent"
"gopkg.in/alecthomas/kingpin.v2"
)
// Version is the steward version (set during build)
var Version = "unreleased"
func main() {
klog.InitFlags(nil)
flag.Set("logtostderr", "true")
flag.Set("v", "3")
klog.Info("Starting SYN cluster agent 🕵️")
klog.Infof("Version %s", Version)
app := kingpin.New("steward", "Steward makes your Kubernetes cluster SYN managed. 🎉")
app.DefaultEnvars()
app.Version(Version)
ctx, cancel := context.WithCancel(context.Background())
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, syscall.SIGTERM)
go receiveSignal(signalCh, cancel)
agent := agent.Agent{}
app.Action(func(*kingpin.ParseContext) error {
return agent.Run(ctx)
})
app.Flag("api", "API URL to connect to").Required().URLVar(&agent.APIURL)
app.Flag("token", "Token to authenticate to the API").Required().StringVar(&agent.Token)
app.Flag("cluster-id", "ID of own cluster").Required().StringVar(&agent.ClusterID)
app.Flag("cloud", "Cloud type this cluster is running on").StringVar(&agent.CloudType)
app.Flag("region", "Cloud region this cluster is running in").StringVar(&agent.CloudRegion)
app.Flag("distribution", "Kubernetes distribution this cluster is running").StringVar(&agent.Distribution)
app.Flag("namespace", "Namespace in which steward is running").Default("syn").StringVar(&agent.Namespace)
app.Flag("argo-image", "Image to be used for the Argo CD deployments").Default("docker.io/argoproj/argocd:v1.4.2").StringVar(&agent.ArgoCDImage)
kingpin.MustParse(app.Parse(os.Args[1:]))
}
func receiveSignal(signalCh chan os.Signal, cancel context.CancelFunc) {
for {
select {
case sig := <-signalCh:
klog.V(3).Infof("Received signal '%v'", sig)
cancel()
}
}
}