cluster

package
v0.0.0-...-4297e01 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2015 License: Apache-2.0, MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEngineNotConnected = errors.New("engine is not connected to docker's REST API")
)

Functions

This section is empty.

Types

type Cluster

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

func New

func New(manager *ResourceManager, engines ...*Engine) (*Cluster, error)

func (*Cluster) AddEngine

func (c *Cluster) AddEngine(e *Engine) error

func (*Cluster) Close

func (c *Cluster) Close() error

Close signals to the cluster that no other actions will be applied

func (*Cluster) ClusterInfo

func (c *Cluster) ClusterInfo() *ClusterInfo

Info returns information about the cluster

func (*Cluster) Engines

func (c *Cluster) Engines() []*Engine

Engines returns the engines registered in the cluster

func (*Cluster) Kill

func (c *Cluster) Kill(container *Container, sig int) error

func (*Cluster) ListContainers

func (c *Cluster) ListContainers(all bool, size bool, filter string) []*Container

ListContainers returns all the containers running in the cluster

func (*Cluster) Remove

func (c *Cluster) Remove(container *Container) error

func (*Cluster) RemoveEngine

func (c *Cluster) RemoveEngine(e *Engine) error

func (*Cluster) Restart

func (c *Cluster) Restart(container *Container, timeout int) error

func (*Cluster) Start

func (c *Cluster) Start(image *Image, pull bool) (*Container, error)

func (*Cluster) Stop

func (c *Cluster) Stop(container *Container) error

type ClusterInfo

type ClusterInfo struct {
	Cpus           float64 `json:"cpus,omitempty"`
	Memory         float64 `json:"memory,omitempty"`
	ContainerCount int     `json:"container_count,omitempty"`
	EngineCount    int     `json:"engine_count,omitempty"`
	ImageCount     int     `json:"image_count,omitempty"`
	ReservedCpus   float64 `json:"reserved_cpus,omitempty"`
	ReservedMemory float64 `json:"reserved_memory,omitempty"`
	Version        string  `json:"version,omitempty"`
}

type Container

type Container struct {
	// ID is the container's id
	ID string `json:"id,omitempty"`

	// Name is the container's name
	Name string `json:"name,omitempty"`

	// Image is the configuration from which the container was created
	Image *Image `json:"image,omitempty"`

	// Engine is the engine that is runnnig the container
	Engine *Engine `json:"engine,omitempty"`

	// State is the container state ( running stopped )
	State string `json:"state,omitempty"`

	// Ports are the public port mappings for the container
	Ports []*Port `json:"ports,omitempty"`
}

Container is a running instance

func FromDockerContainer

func FromDockerContainer(id, image string, engine *Engine) (*Container, error)

func (*Container) String

func (c *Container) String() string

type Engine

type Engine struct {
	ID     string   `json:"id,omitempty"`
	Addr   string   `json:"addr,omitempty"`
	Cpus   float64  `json:"cpus,omitempty"`
	Memory float64  `json:"memory,omitempty"`
	Labels []string `json:"labels,omitempty"`
	// contains filtered or unexported fields
}

func (*Engine) Connect

func (e *Engine) Connect(config *tls.Config) error

func (*Engine) IsConnected

func (e *Engine) IsConnected() bool

IsConnected returns true if the engine is connected to a remote docker API

func (*Engine) Kill

func (e *Engine) Kill(container *Container, sig int) error

func (*Engine) ListContainers

func (e *Engine) ListContainers(all bool, size bool, filter string) ([]*Container, error)

func (*Engine) ListImages

func (e *Engine) ListImages() ([]string, error)

func (*Engine) Pull

func (e *Engine) Pull(image string) error

func (*Engine) Remove

func (e *Engine) Remove(container *Container) error

func (*Engine) Restart

func (e *Engine) Restart(container *Container, timeout int) error

func (*Engine) SetClient

func (e *Engine) SetClient(c *dockerclient.DockerClient)

func (*Engine) SetClientAuth

func (e *Engine) SetClientAuth(username, password, email string)

func (*Engine) Start

func (e *Engine) Start(c *Container, pullImage bool) error

func (*Engine) Stop

func (e *Engine) Stop(container *Container) error

func (*Engine) String

func (e *Engine) String() string

func (*Engine) Version

func (e *Engine) Version() (*dockerclient.Version, error)

type EngineSnapshot

type EngineSnapshot struct {
	// ID is the engines id
	ID string `json:"id,omitempty"`

	Cpus float64 `json:"cpus,omitempty"`

	Memory float64 `json:"memory,omitempty"`

	// ReservedCpus is the total amount of cpus that is reserved
	ReservedCpus float64 `json:"reserved_cpus,omitempty"`

	// ReservedMemory is the total amount of memory that is reserved
	ReservedMemory float64 `json:"reserved_memory,omitempty"`

	// CurrentMemory is the current system's used memory at the time of the snapshot
	CurrentMemory float64 `json:"current_memory,omitempty"`

	// CurrentCpu is the current system's cpu usage at the time of the snapshot
	CurrentCpu float64 `json:"current_cpu,omitempty"`
}

type Image

type Image struct {
	// Name is the docker image to base the container off of
	Name string `json:"name,omitempty"`

	// Cpus is the number of cpu resources to give to the container
	Cpus float64 `json:"cpus,omitempty"`

	// Cpuset is the single or multiple set of cpus on which the container can run
	Cpuset string `json:"cpuset,omitempty"`

	// Memory is the amount of memory in MB for the container
	Memory float64 `json:"memory,omitempty"`

	// Entrypoint is the entrypoint in the container
	Entrypoint []string `json:"entrypoint,omitempty"`

	// Envionrment is the environment vars to set on the container
	Environment map[string]string `json:"environment,omitempty"`

	// Hostname is the host name to set for the container
	Hostname string `json:"hostname,omitempty"`

	// Domainname is the domain name to set for the container
	Domainname string `json:"domain,omitempty"`

	// Args are cli arguments to pass to the image
	Args []string `json:"args,omitempty"`

	// Type is the container type, often service, batch, etc...
	Type string `json:"type,omitempty"`

	// Labels are matched with constraints on the engines
	Labels []string `json:"labels,omitempty"`

	// BindPorts ensures that the container has exclusive access to the specified ports
	BindPorts []*Port `json:"bind_ports,omitempty"`

	// UserData is user defined data that is passed to the container
	UserData map[string][]string `json:"user_data,omitempty"`

	// Volumes are volumes on the same engine
	Volumes []string `json:"volumes,omitempty"`

	// Links are mappings to other containers running on the same engine
	Links map[string]string `json:"links,omitempty"`

	// RestartPolicy is the container restart policy if it exits
	RestartPolicy RestartPolicy `json:"restart_policy,omitempty"`

	// Publish tells the engine to expose ports the the container externally
	Publish bool `json:"publish,omitempty"`

	// Give extended privileges to this container, e.g. Docker-in-Docker
	Privileged bool `json:"privileged,omitempty"`

	// NetworkMode is the network mode for the container
	NetworkMode string `json:"network_mode,omitempty"`

	// ContainerName is the name set to the container
	ContainerName string `json:"container_name,omitempty"`
}

Image is a template for running a docker container

func (*Image) String

func (i *Image) String() string

type ImageInfo

type ImageInfo struct {
	Name string
	Tag  string
}

func ParseImageName

func ParseImageName(name string) *ImageInfo

type Port

type Port struct {
	Proto         string `json:"proto,omitempty"`
	HostIp        string `json:"host_ip,omitempty"`
	Port          int    `json:"port,omitempty"`
	ContainerPort int    `json:"container_port,omitempty"`
}

type ResourceManager

type ResourceManager struct {
}

ResourceManager is responsible for managing the engines of the cluster

func NewResourceManager

func NewResourceManager() *ResourceManager

func (*ResourceManager) PlaceContainer

func (r *ResourceManager) PlaceContainer(c *Container,
	engines []*EngineSnapshot) (*EngineSnapshot, error)

PlaceImage uses the provided engines to make a decision on which resource the container should run based on best utilization of the engines.

type RestartPolicy

type RestartPolicy struct {
	Name              string `json:"name,omitempty"`
	MaximumRetryCount int64  `json:"maximum_retry,omitempty"`
}

Jump to

Keyboard shortcuts

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