mesos

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2017 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "mesos",
	Short: "Hatchery mesos commands: hatchery mesos --help",
	Long: `Hatchery mesos commands: hatchery mesos <command>
Start worker model instances on a mesos cluster

$ cds generate token --group shared.infra --expiration persistent
2706bda13748877c57029598b915d46236988c7c57ea0d3808524a1e1a3adef4

$ hatchery mesos --api=https://<api.domain> --token=<token>

	`,
	Run: func(cmd *cobra.Command, args []string) {
		hatchery.Born(hatcheryMesos, viper.GetString("api"), viper.GetString("token"), viper.GetInt("provision"), viper.GetInt("request-api-timeout"), viper.GetBool("insecure"))
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		hatcheryMesos.token = viper.GetString("token")

		hatcheryMesos.marathonHost = viper.GetString("marathon-host")
		if hatcheryMesos.marathonHost == "" {
			sdk.Exit("flag or environmnent variable marathon-host not provided, aborting\n")
		}

		hatcheryMesos.marathonID = viper.GetString("marathon-id")
		if hatcheryMesos.marathonID == "" {
			sdk.Exit("flag or environmnent variable marathon-id not provided, aborting\n")
		}

		hatcheryMesos.marathonVHOST = viper.GetString("marathon-vhost")
		if hatcheryMesos.marathonVHOST == "" {
			sdk.Exit("flag or environmnent variable marathon-vhost not provided, aborting\n")
		}

		hatcheryMesos.marathonUser = viper.GetString("marathon-user")
		if hatcheryMesos.marathonUser == "" {
			sdk.Exit("flag or environmnent variable marathon-user not provided, aborting\n")
		}

		hatcheryMesos.marathonPassword = viper.GetString("marathon-password")
		if hatcheryMesos.marathonPassword == "" {
			sdk.Exit("flag or environmnent variable marathon-password not provided, aborting\n")
		}

		hatcheryMesos.marathonLabelsString = viper.GetString("marathon-labels")
		hatcheryMesos.marathonLabels = map[string]string{}
		if hatcheryMesos.marathonLabelsString != "" {
			array := strings.Split(hatcheryMesos.marathonLabelsString, ",")
			for _, s := range array {
				if !strings.Contains(s, "=") {
					continue
				}
				tuple := strings.Split(s, "=")
				if len(tuple) != 2 {
					sdk.Exit("malformatted flag or environmnent variable marathon-labels")
				}
				hatcheryMesos.marathonLabels[tuple[0]] = tuple[1]
			}
		}

	},
}

Cmd configures comamnd for HatcheryLocal

Functions

This section is empty.

Types

type Application

type Application struct {
	ID                    string            `json:"id,omitempty"`
	Cmd                   string            `json:"cmd,omitempty"`
	Args                  []string          `json:"args"`
	Constraints           [][]string        `json:"constraints"`
	CPUs                  float64           `json:"cpus,omitempty"`
	Disk                  float64           `json:"disk,omitempty"`
	Env                   map[string]string `json:"env"`
	Executor              string            `json:"executor,omitempty"`
	Instances             int               `json:"instances,omitempty"`
	Mem                   float64           `json:"mem,omitempty"`
	Ports                 []int             `json:"ports"`
	RequirePorts          bool              `json:"requirePorts,omitempty"`
	BackoffSeconds        float64           `json:"backoffSeconds,omitempty"`
	BackoffFactor         float64           `json:"backoffFactor,omitempty"`
	MaxLaunchDelaySeconds float64           `json:"maxLaunchDelaySeconds,omitempty"`
	Dependencies          []string          `json:"dependencies"`
	TasksRunning          int               `json:"tasksRunning,omitempty"`
	TasksStaged           int               `json:"tasksStaged,omitempty"`
	TasksHealthy          int               `json:"tasksHealthy,omitempty"`
	TasksUnhealthy        int               `json:"tasksUnhealthy,omitempty"`
	User                  string            `json:"user,omitempty"`
	Uris                  []string          `json:"uris"`
	Version               string            `json:"version,omitempty"`
	Labels                map[string]string `json:"labels,omitempty"`
	AcceptedResourceRoles []string          `json:"acceptedResourceRoles,omitempty"`
}

Application is the definition for an application in marathon

type Applications

type Applications struct {
	Apps []Application `json:"apps"`
}

Applications is a collection of applications

type HatcheryMesos

type HatcheryMesos struct {
	// contains filtered or unexported fields
}

HatcheryMesos implements HatcheryMode interface for mesos mode

func (*HatcheryMesos) CanSpawn

func (m *HatcheryMesos) CanSpawn(model *sdk.Model, req []sdk.Requirement) bool

CanSpawn return wether or not hatchery can spawn model requirements services are not supported

func (*HatcheryMesos) Hatchery

func (m *HatcheryMesos) Hatchery() *sdk.Hatchery

Hatchery returns hatchery instance

func (*HatcheryMesos) ID

func (m *HatcheryMesos) ID() int64

ID must returns hatchery id

func (*HatcheryMesos) Init

func (m *HatcheryMesos) Init() error

Init only starts killing routine of worker not registered

func (*HatcheryMesos) KillWorker

func (m *HatcheryMesos) KillWorker(worker sdk.Worker) error

KillWorker deletes an application on mesos via marathon

func (*HatcheryMesos) SpawnWorker

func (m *HatcheryMesos) SpawnWorker(model *sdk.Model, req []sdk.Requirement) error

SpawnWorker creates an application on mesos via marathon requirements services are not supported

func (*HatcheryMesos) WorkerStarted

func (m *HatcheryMesos) WorkerStarted(model *sdk.Model) int

WorkerStarted returns the number of instances of given model started but not necessarily register on CDS yet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL