Documentation
¶
Overview ¶
Package cluster provides types and functions for management of Docker clusters, scheduling container operations among hosts running Docker (nodes).
Index ¶
- Constants
- Variables
- type Bridge
- type Bridges
- type Cluster
- func (c *Cluster) AttachToContainer(opts docker.AttachToContainerOptions) error
- func (c *Cluster) BuildImage(buildOptions docker.BuildImageOptions) error
- func (c *Cluster) CommitContainer(opts docker.CommitContainerOptions) (*docker.Image, error)
- func (c *Cluster) CreateContainer(opts docker.CreateContainerOptions) (string, *docker.Container, error)
- func (c *Cluster) CreateContainerSchedulerOpts(opts docker.CreateContainerOptions) (string, *docker.Container, error)
- func (c *Cluster) CreateExec(opts docker.CreateExecOptions) (*docker.Exec, error)
- func (c *Cluster) ExportContainer(opts docker.ExportContainerOptions) error
- func (c *Cluster) GetIP() (net.IP, string, string, error)
- func (c *Cluster) ImportImage(opts docker.ImportImageOptions) error
- func (c *Cluster) InspectContainer(id string) (*docker.Container, error)
- func (c *Cluster) InspectExec(execId, containerId string) (*docker.ExecInspect, error)
- func (c *Cluster) InspectImage(repo string) (*docker.Image, error)
- func (c *Cluster) KillContainer(opts docker.KillContainerOptions) error
- func (c *Cluster) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
- func (c *Cluster) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
- func (c *Cluster) Logs(opts docker.LogsOptions) error
- func (c *Cluster) Nodes() ([]Node, error)
- func (c *Cluster) NodesForMetadata(metadata map[string]string) ([]Node, error)
- func (c *Cluster) PauseContainer(id string) error
- func (c *Cluster) PreStopAction(name string) (string, error)
- func (c *Cluster) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration, nodes ...string) error
- func (c *Cluster) PushImage(opts docker.PushImageOptions, auth docker.AuthConfiguration) error
- func (c *Cluster) Register(node Node) error
- func (c *Cluster) RemoveContainer(opts docker.RemoveContainerOptions) error
- func (c *Cluster) RemoveFromRegistry(imageId string) error
- func (c *Cluster) RemoveImage(name string) error
- func (c *Cluster) RemoveImageIgnoreLast(name string) error
- func (c *Cluster) ResizeExecTTY(execId, containerId string, height, width int) error
- func (c *Cluster) RestartContainer(id string, timeout uint) error
- func (c *Cluster) SetLogs(containerId string, containerName string) error
- func (c *Cluster) SetNetworkinNode(containerId string, ip string, gateway string, bridge string) error
- func (c *Cluster) StartContainer(id string, hostConfig *docker.HostConfig) error
- func (c *Cluster) StartExec(execId, containerId string, opts docker.StartExecOptions) error
- func (c *Cluster) StopContainer(id string, timeout uint) error
- func (c *Cluster) TagImage(name string, opts docker.TagImageOptions) error
- func (c *Cluster) TopContainer(id string, psArgs string) (docker.TopResult, error)
- func (c *Cluster) UnfilteredNodes() ([]Node, error)
- func (c *Cluster) UnpauseContainer(id string) error
- func (c *Cluster) Unregister(address string) error
- func (c *Cluster) UpdateNode(node Node) (Node, error)
- func (c *Cluster) WaitContainer(id string) (int, error)
- type Container
- type ContainerStorage
- type DefaultHealer
- type DockerClient
- type DockerNodeError
- type Gulp
- type Healer
- type HealingData
- type IPIndex
- type Image
- type ImageHistory
- type ImageStorage
- type MapStorage
- func (s *MapStorage) ExtendNodeLock(address string, timeout time.Duration) error
- func (s *MapStorage) LockNodeForHealing(address string, isFailure bool, timeout time.Duration) (bool, error)
- func (s *MapStorage) RemoveContainer(containerID string) error
- func (s *MapStorage) RemoveImage(repo, id, host string) error
- func (s *MapStorage) RemoveNode(addr string) error
- func (s *MapStorage) RetrieveContainer(containerID string) (string, error)
- func (s *MapStorage) RetrieveContainerByName(Name string) (string, error)
- func (s *MapStorage) RetrieveContainers() ([]Container, error)
- func (s *MapStorage) RetrieveImage(repo string) (Image, error)
- func (s *MapStorage) RetrieveImages() ([]Image, error)
- func (s *MapStorage) RetrieveNode(address string) (Node, error)
- func (s *MapStorage) RetrieveNodes() ([]Node, error)
- func (s *MapStorage) RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error)
- func (s *MapStorage) StoreContainer(containerID, hostID string) error
- func (s *MapStorage) StoreContainerByName(containerID, Name string) error
- func (s *MapStorage) StoreImage(repo, id, host string) error
- func (s *MapStorage) StoreNode(node Node) error
- func (s *MapStorage) UnlockNode(address string) error
- func (s *MapStorage) UpdateNode(node Node) error
- type Node
- type NodeList
- type NodeStorage
- type Storage
Constants ¶
const ( DOCKER_NETWORK = "/docker/networks" DOCKER_LOGS = "/docker/logs" HTTP = "http://" )
const ( NodeStatusWaiting = "waiting" NodeStatusReady = "ready" NodeStatusRetry = "ready for retry" NodeStatusDisabled = "disabled" NodeStatusHealing = "healing" NodeCreationStatusCreated = "created" NodeCreationStatusError = "error" NodeCreationStatusPending = "pending" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { Healer Healer // contains filtered or unexported fields }
Cluster is the basic type of the package. It manages internal nodes, and provide methods for interaction with those nodes, like CreateContainer, which creates a container in one node of the cluster.
func New ¶
New creates a new Cluster, initially composed by the given nodes.
The scheduler parameter defines the scheduling strategy. It defaults to round robin if nil. The storage parameter is the storage the cluster instance will use.
func (*Cluster) AttachToContainer ¶
AttachToContainer attaches to a container, using the given options.
func (*Cluster) BuildImage ¶
BuildImage build an image and pushes it to registry
func (*Cluster) CommitContainer ¶
CommitContainer commits a container and returns the image id.
func (*Cluster) CreateContainer ¶
func (c *Cluster) CreateContainer(opts docker.CreateContainerOptions) (string, *docker.Container, error)
CreateContainer creates a container in the specified node. If no node is specified, it will create the container in a node selected by the scheduler.
It returns the container, or an error, in case of failures.
func (*Cluster) CreateContainerSchedulerOpts ¶
func (c *Cluster) CreateContainerSchedulerOpts(opts docker.CreateContainerOptions) (string, *docker.Container, error)
Similar to CreateContainer but allows arbritary options to be passed to the scheduler.
func (*Cluster) CreateExec ¶
func (*Cluster) ExportContainer ¶
ExportContainer exports a container as a tar and writes the result in out.
func (*Cluster) ImportImage ¶
ImportImage imports an image from a url or stdin
func (*Cluster) InspectContainer ¶
InspectContainer returns information about a container by its ID, getting the information from the right node.
func (*Cluster) InspectExec ¶
func (*Cluster) InspectImage ¶
InspectContainer inspects an image based on its repo name
func (*Cluster) KillContainer ¶
KillContainer kills a container, returning an error in case of failure.
func (*Cluster) ListContainers ¶
ListContainers returns a slice of all containers in the cluster matching the given criteria.
func (*Cluster) ListImages ¶
ListImages lists images existing in each cluster node
func (*Cluster) NodesForMetadata ¶
func (*Cluster) PauseContainer ¶
PauseContainer changes the container to the paused state.
func (*Cluster) PullImage ¶
func (c *Cluster) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration, nodes ...string) error
PullImage pulls an image from a remote registry server, returning an error in case of failure.
It will pull all images in parallel, so users need to make sure that the given buffer is safe.
func (*Cluster) PushImage ¶
PushImage pushes an image to a remote registry server, returning an error in case of failure.
func (*Cluster) RemoveContainer ¶
RemoveContainer removes a container from the cluster.
func (*Cluster) RemoveFromRegistry ¶
func (*Cluster) RemoveImage ¶
RemoveImage removes an image from the nodes where this images exists, returning an error in case of failure. Will wait for the image to be removed on all nodes.
func (*Cluster) RemoveImageIgnoreLast ¶
RemoveImageIgnoreLast works similarly to RemoveImage except it won't remove the last built/pulled/commited image.
func (*Cluster) ResizeExecTTY ¶
func (*Cluster) RestartContainer ¶
RestartContainer restarts a container, killing it after the given timeout, if it fails to stop nicely.
func (*Cluster) SetNetworkinNode ¶
func (*Cluster) StartContainer ¶
func (*Cluster) StopContainer ¶
StopContainer stops a container, killing it after the given timeout, if it fails to stop nicely.
func (*Cluster) TagImage ¶
TagImage adds a tag to the given image, returning an error in case of failure.
func (*Cluster) TopContainer ¶
TopContainer returns information about running processes inside a container by its ID, getting the information from the right node.
func (*Cluster) UnfilteredNodes ¶
func (*Cluster) UnpauseContainer ¶
UnpauseContainer removes the container from the paused state.
func (*Cluster) Unregister ¶
Unregister removes nodes from the cluster.
type ContainerStorage ¶
type ContainerStorage interface { StoreContainer(container, host string) error RetrieveContainer(container string) (host string, err error) RemoveContainer(container string) error RetrieveContainers() ([]Container, error) StoreContainerByName(container, host string) error RetrieveContainerByName(name string) (container string, err error) }
ContainerStorage provides methods to store and retrieve information about the relation between the node and the container. It can be easily represented as a key-value storage.
The relevant information is: in which host the given container is running?
type DefaultHealer ¶
type DefaultHealer struct{}
func (DefaultHealer) HandleError ¶
func (DefaultHealer) HandleError(node *Node) time.Duration
type DockerClient ¶
type DockerClient struct { ContainerName string ContainerId string Bridge string IpAddr string Gateway string }
func (*DockerClient) LogsRequest ¶
func (d *DockerClient) LogsRequest(url string, port string) error
func (*DockerClient) NetworkRequest ¶
func (d *DockerClient) NetworkRequest(url string, port string) error
type DockerNodeError ¶
type DockerNodeError struct {
// contains filtered or unexported fields
}
func (DockerNodeError) BaseError ¶
func (n DockerNodeError) BaseError() error
func (DockerNodeError) Error ¶
func (n DockerNodeError) Error() string
type HealingData ¶
type Image ¶
type Image struct { Repository string LastNode string LastId string History []ImageHistory }
type ImageHistory ¶
type ImageStorage ¶
type ImageStorage interface { StoreImage(repo, id, host string) error RetrieveImage(repo string) (Image, error) RemoveImage(repo, id, host string) error RetrieveImages() ([]Image, error) }
ImageStorage works like ContainerStorage, but stores information about images and hosts.
type MapStorage ¶
type MapStorage struct {
// contains filtered or unexported fields
}
func (*MapStorage) ExtendNodeLock ¶
func (s *MapStorage) ExtendNodeLock(address string, timeout time.Duration) error
func (*MapStorage) LockNodeForHealing ¶
func (*MapStorage) RemoveContainer ¶
func (s *MapStorage) RemoveContainer(containerID string) error
func (*MapStorage) RemoveImage ¶
func (s *MapStorage) RemoveImage(repo, id, host string) error
func (*MapStorage) RemoveNode ¶
func (s *MapStorage) RemoveNode(addr string) error
func (*MapStorage) RetrieveContainer ¶
func (s *MapStorage) RetrieveContainer(containerID string) (string, error)
func (*MapStorage) RetrieveContainerByName ¶
func (s *MapStorage) RetrieveContainerByName(Name string) (string, error)
func (*MapStorage) RetrieveContainers ¶
func (s *MapStorage) RetrieveContainers() ([]Container, error)
func (*MapStorage) RetrieveImage ¶
func (s *MapStorage) RetrieveImage(repo string) (Image, error)
func (*MapStorage) RetrieveImages ¶
func (s *MapStorage) RetrieveImages() ([]Image, error)
func (*MapStorage) RetrieveNode ¶
func (s *MapStorage) RetrieveNode(address string) (Node, error)
func (*MapStorage) RetrieveNodes ¶
func (s *MapStorage) RetrieveNodes() ([]Node, error)
func (*MapStorage) RetrieveNodesByMetadata ¶
func (s *MapStorage) RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error)
func (*MapStorage) StoreContainer ¶
func (s *MapStorage) StoreContainer(containerID, hostID string) error
func (*MapStorage) StoreContainerByName ¶
func (s *MapStorage) StoreContainerByName(containerID, Name string) error
func (*MapStorage) StoreImage ¶
func (s *MapStorage) StoreImage(repo, id, host string) error
func (*MapStorage) StoreNode ¶
func (s *MapStorage) StoreNode(node Node) error
func (*MapStorage) UnlockNode ¶
func (s *MapStorage) UnlockNode(address string) error
func (*MapStorage) UpdateNode ¶
func (s *MapStorage) UpdateNode(node Node) error
type Node ¶
type Node struct { Address string Healing HealingData Metadata map[string]string CreationStatus string }
Node represents a host running Docker. Each node has an Address (in the form <scheme>://<host>:<port>/) and map with arbritary metadata.
func (*Node) CleanMetadata ¶
func (*Node) FailureCount ¶
func (*Node) HasSuccess ¶
func (Node) MarshalJSON ¶
func (*Node) ResetFailures ¶
func (n *Node) ResetFailures()
type NodeStorage ¶
type NodeStorage interface { StoreNode(node Node) error RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error) RetrieveNodes() ([]Node, error) RetrieveNode(address string) (Node, error) UpdateNode(node Node) error RemoveNode(address string) error LockNodeForHealing(address string, isFailure bool, timeout time.Duration) (bool, error) ExtendNodeLock(address string, timeout time.Duration) error UnlockNode(address string) error }
type Storage ¶
type Storage interface { ContainerStorage ImageStorage NodeStorage }