Esempio n. 1
0
func main() {
	app := cli.NewApp()
	app.Name = "convoy-agent"
	app.Version = GITCOMMIT
	app.Author = "Rancher Labs"
	app.Usage = "An agent that acts as an interface between rancher storage and cattle server"

	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "debug, d",
			Usage: "enable debug logging level",
		},
		cli.StringFlag{
			Name:   "url",
			Usage:  "The URL endpoint to communicate with cattle server",
			EnvVar: "CATTLE_URL",
		},
		cli.StringFlag{
			Name:   "access-key",
			Usage:  "The access key required to authenticate with cattle server",
			EnvVar: "CATTLE_ACCESS_KEY",
		},
		cli.StringFlag{
			Name:   "secret-key",
			Usage:  "The secret key required to authenticate with cattle server",
			EnvVar: "CATTLE_SECRET_KEY",
		},
		cli.IntFlag{
			Name:  "healthcheck-interval",
			Value: 5,
			Usage: "set the frequency of performing healthchecks",
		},
		cli.StringFlag{
			Name:  "healthcheck-basedir",
			Value: ".healthcheck",
			Usage: "set the directory to write the healthcheck files into",
		},
		cli.StringFlag{
			Name:  "storagepool-rootdir",
			Usage: "set the storage pool rootdir",
			Value: ".root",
		},
		cli.StringFlag{
			Name:  "storagepool-driver",
			Usage: "set the storage pool driver.",
		},
	}

	commands := append(volume.Commands, storagepool.Commands...)
	app.Commands = commands

	go func() {
		err := healthcheck.StartHealthCheck(port)
		log.Fatalf("Error while running healthcheck [%v]", err)
	}()
	app.EnableBashCompletion = true
	app.Run(os.Args)
}
Esempio n. 2
0
func launch(c *cli.Context) {
	conf := config.Conf(c)

	resultChan := make(chan error)

	rClient, err := config.GetRancherClient(conf)
	if err != nil {
		log.Fatal(err)
	}

	kClient := kubernetesclient.NewClient(conf.KubernetesURL, true)

	svcHandler := kubernetesevents.NewHandler(rClient, kClient, kubernetesevents.ServiceKind)
	handlers := []kubernetesevents.Handler{svcHandler}

	log.Info("Watching changes for kinds: ", c.StringSlice("watch-kind"))
	for _, kind := range c.StringSlice("watch-kind") {
		handlers = append(handlers, kubernetesevents.NewChangeHandler(rClient, kClient, kind))
	}

	go func(rc chan error) {
		err := kubernetesevents.ConnectToEventStream(handlers, conf)
		log.Errorf("Kubernetes stream listener exited with error: %s", err)
		rc <- err
	}(resultChan)

	go func(rc chan error) {
		err := rancherevents.ConnectToEventStream(conf)
		log.Errorf("Rancher stream listener exited with error: %s", err)
		rc <- err
	}(resultChan)

	go func(rc chan error) {
		err := healthcheck.StartHealthCheck(conf.HealthCheckPort)
		log.Errorf("Rancher healthcheck exited with error: %s", err)
		rc <- err
	}(resultChan)

	<-resultChan
	log.Info("Exiting.")
}
Esempio n. 3
0
func launch(c *cli.Context) {
	conf := config.Conf(c)

	resultChan := make(chan error)

	rClient, err := config.GetRancherClient(conf)
	if err != nil {
		log.Fatal(err)
	}

	kClient := kubernetesclient.NewClient(conf.KubernetesURL, true)

	rcHandler := kubernetesevents.NewHandler(rClient, kClient, kubernetesevents.RCKind)
	svcHandler := kubernetesevents.NewHandler(rClient, kClient, kubernetesevents.ServiceKind)
	handlers := []kubernetesevents.Handler{rcHandler, svcHandler}

	go func(rc chan error) {
		err := kubernetesevents.ConnectToEventStream(handlers, conf)
		log.Errorf("Kubernetes stream listener exited with error: %s", err)
		rc <- err
	}(resultChan)

	go func(rc chan error) {
		err := rancherevents.ConnectToEventStream(conf)
		log.Errorf("Rancher stream listener exited with error: %s", err)
		rc <- err
	}(resultChan)

	go func(rc chan error) {
		err := healthcheck.StartHealthCheck(conf.HealthCheckPort)
		log.Errorf("Rancher healthcheck exited with error: %s", err)
		rc <- err
	}(resultChan)

	<-resultChan
	log.Info("Exiting.")
}