-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
46 lines (36 loc) · 1.13 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 (
"context"
"os"
"github.com/namsral/flag"
"k8s.io/api/apps/v1beta1"
"k8s.io/klog"
)
func main() {
ctx := context.Background()
namespaces := flag.String("namespaces", "", "namespaces to watch separated by commas")
inCluster := flag.Bool("in_cluster", true, "Boolean that indicate if your are inside the cluster or not")
rmqURL := flag.String("rmq_url", "", "RMQ Host URL")
rmqUser := flag.String("rmq_user", "", "RMQ Username used for authentication with the RabbitMQ API")
rmqPassword := flag.String("rmq_password", "", "RMQ Password used for authentication with the RabbitMQ API")
loopTick := flag.Int("tick", 10, "Seconds between checks for autoscaling scale")
flag.Parse()
rmq, err := newRmq(*rmqURL, *rmqUser, *rmqPassword)
if err != nil {
klog.Error(err)
os.Exit(128)
}
hub := &Autoscaler{
rmq: rmq,
apps: make(map[string]*App),
add: make(chan *v1beta1.Deployment),
delete: make(chan *v1beta1.Deployment),
}
k8sClient, err := discover(ctx, hub, *inCluster, *namespaces)
if err != nil {
klog.Error(err)
os.Exit(128)
}
go hub.Run(ctx, k8sClient, *loopTick)
<-ctx.Done()
}