Documentation ¶
Index ¶
- Variables
- type Cluster
- func (c *Cluster) AddEngine(e *Engine) error
- func (c *Cluster) Close() error
- func (c *Cluster) ClusterInfo() *ClusterInfo
- func (c *Cluster) Engines() []*Engine
- func (c *Cluster) Kill(container *Container, sig int) error
- func (c *Cluster) ListContainers(all bool, size bool, filter string) []*Container
- func (c *Cluster) Remove(container *Container) error
- func (c *Cluster) RemoveEngine(e *Engine) error
- func (c *Cluster) Restart(container *Container, timeout int) error
- func (c *Cluster) Start(image *Image, pull bool) (*Container, error)
- func (c *Cluster) Stop(container *Container) error
- type ClusterInfo
- type Container
- type Engine
- func (e *Engine) Connect(config *tls.Config) error
- func (e *Engine) IsConnected() bool
- func (e *Engine) Kill(container *Container, sig int) error
- func (e *Engine) ListContainers(all bool, size bool, filter string) ([]*Container, error)
- func (e *Engine) ListImages() ([]string, error)
- func (e *Engine) Pull(image string) error
- func (e *Engine) Remove(container *Container) error
- func (e *Engine) Restart(container *Container, timeout int) error
- func (e *Engine) SetClient(c *dockerclient.DockerClient)
- func (e *Engine) SetClientAuth(username, password, email string)
- func (e *Engine) Start(c *Container, pullImage bool) error
- func (e *Engine) Stop(container *Container) error
- func (e *Engine) String() string
- func (e *Engine) Version() (*dockerclient.Version, error)
- type EngineSnapshot
- type Image
- type ImageInfo
- type Port
- type ResourceManager
- type RestartPolicy
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 (*Cluster) ClusterInfo ¶
func (c *Cluster) ClusterInfo() *ClusterInfo
Info returns information about the cluster
func (*Cluster) ListContainers ¶
ListContainers returns all the containers running in the cluster
func (*Cluster) RemoveEngine ¶
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 ¶
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) IsConnected ¶
IsConnected returns true if the engine is connected to a remote docker API
func (*Engine) ListContainers ¶
func (*Engine) ListImages ¶
func (*Engine) SetClient ¶
func (e *Engine) SetClient(c *dockerclient.DockerClient)
func (*Engine) SetClientAuth ¶
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
type ImageInfo ¶
func ParseImageName ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.