Documentation ¶
Index ¶
- Constants
- func ConsolidateResourceFields(c *OldContainerConfig)
- func FullStateString(state *types.ContainerState) string
- func NewHTTPClientTimeout(daemonUrl string, tlsConfig *tls.Config, timeout time.Duration, ...) (*http.Client, *url.URL, error)
- func ParseRepositoryTag(repos string) (string, string)
- func StateString(state *types.ContainerState) string
- type Cluster
- type Container
- type ContainerConfig
- func (c *ContainerConfig) AddAffinity(affinity string) error
- func (c *ContainerConfig) AddConstraint(constraint string) error
- func (c *ContainerConfig) Affinities() []string
- func (c *ContainerConfig) Constraints() []string
- func (c *ContainerConfig) HasReschedulePolicy(p string) bool
- func (c *ContainerConfig) HaveNodeConstraint() bool
- func (c *ContainerConfig) RemoveAffinity(affinity string) error
- func (c *ContainerConfig) SetSwarmID(id string)
- func (c *ContainerConfig) SwarmID() string
- func (c *ContainerConfig) Validate() error
- type Containers
- type DriverOpts
- func (do DriverOpts) Bool(key, env string) (bool, bool)
- func (do DriverOpts) Float(key, env string) (float64, bool)
- func (do DriverOpts) IP(key, env string) (net.IP, bool)
- func (do DriverOpts) Int(key, env string) (int64, bool)
- func (do DriverOpts) String(key, env string) (string, bool)
- func (do DriverOpts) Uint(key, env string) (uint64, bool)
- type Engine
- func (e *Engine) AddContainer(container *Container) error
- func (e *Engine) AddNetwork(network *Network)
- func (e *Engine) BuildImage(buildContext io.Reader, buildImage *types.ImageBuildOptions) (io.ReadCloser, error)
- func (e *Engine) CheckConnectionErr(err error)
- func (e *Engine) Connect(config *tls.Config) error
- func (e *Engine) ConnectWithClient(client dockerclient.Client, apiClient swarmclient.SwarmAPIClient) error
- func (e *Engine) Containers() Containers
- func (e *Engine) CreateContainer(config *ContainerConfig, name string, pullImage bool, ...) (*Container, error)
- func (e *Engine) CreateNetwork(name string, request *types.NetworkCreate) (*types.NetworkCreateResponse, error)
- func (e *Engine) CreateVolume(request *volume.VolumesCreateBody) (*types.Volume, error)
- func (e *Engine) DeleteNetwork(network *Network)
- func (e *Engine) Disconnect()
- func (e *Engine) ErrMsg() string
- func (e *Engine) HTTPClientAndScheme() (*http.Client, string, error)
- func (e *Engine) HandleIDConflict(otherAddr string)
- func (e *Engine) HealthIndicator() int64
- func (e *Engine) Image(IDOrName string) *Image
- func (e *Engine) Images() Images
- func (e *Engine) Import(source string, ref string, tag string, imageReader io.Reader) error
- func (e *Engine) IsHealthy() bool
- func (e *Engine) Load(reader io.Reader) error
- func (e *Engine) Networks() Networks
- func (e *Engine) Pull(image string, authConfig *types.AuthConfig) error
- func (e *Engine) RefreshContainers(full bool) error
- func (e *Engine) RefreshImages() error
- func (e *Engine) RefreshNetworks() error
- func (e *Engine) RefreshVolumes() error
- func (e *Engine) RegisterEventHandler(h EventHandler) error
- func (e *Engine) RemoveContainer(container *Container, force, volumes bool) error
- func (e *Engine) RemoveImage(name string, force bool) ([]types.ImageDelete, error)
- func (e *Engine) RemoveNetwork(network *Network) error
- func (e *Engine) RemoveVolume(name string) error
- func (e *Engine) RenameContainer(container *Container, newName string) error
- func (e *Engine) StartContainer(id string, hostConfig *dockerclient.HostConfig) error
- func (e *Engine) StartMonitorEvents()
- func (e *Engine) Status() string
- func (e *Engine) String() string
- func (e *Engine) TagImage(IDOrName string, ref string, force bool) error
- func (e *Engine) TimeToValidate() bool
- func (e *Engine) TotalCpus() int64
- func (e *Engine) TotalMemory() int64
- func (e *Engine) UpdatedAt() time.Time
- func (e *Engine) UsedCpus() int64
- func (e *Engine) UsedMemory() int64
- func (e *Engine) ValidationComplete()
- func (e *Engine) Volumes() Volumes
- type EngineOpts
- type EngineSorter
- type Event
- type EventHandler
- type EventHandlers
- type EventsMonitor
- type Image
- type ImageFilterOptions
- type Images
- type Network
- type Networks
- type OldContainerConfig
- type Volume
- type Volumes
- type Watchdog
Constants ¶
const SwarmLabelNamespace = "com.docker.swarm"
SwarmLabelNamespace defines the key prefix in all custom labels
Variables ¶
This section is empty.
Functions ¶
func ConsolidateResourceFields ¶ added in v1.2.1
func ConsolidateResourceFields(c *OldContainerConfig)
ConsolidateResourceFields is a temporary fix to handle forward/backward compatibility between Docker <1.6 and >=1.7
func FullStateString ¶ added in v1.2.1
func FullStateString(state *types.ContainerState) string
FullStateString returns human-readable description of the state
func NewHTTPClientTimeout ¶ added in v1.2.4
func ParseRepositoryTag ¶ added in v1.1.0
ParseRepositoryTag gets a repos name and returns the right reposName + tag|digest The tag can be confusing because of a port in a repository name.
Ex: localhost.localdomain:5000/samalba/hipache:latest Digest ex: localhost:5000/foo/bar@sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb
func StateString ¶ added in v1.2.1
func StateString(state *types.ContainerState) string
StateString returns a single string to describe state
Types ¶
type Cluster ¶
type Cluster interface { // Create a container CreateContainer(config *ContainerConfig, name string, authConfig *types.AuthConfig) (*Container, error) // Remove a container RemoveContainer(container *Container, force, volumes bool) error // Return all images Images() Images // Return one image matching `IDOrName` Image(IDOrName string) *Image // Remove images from the cluster RemoveImages(name string, force bool) ([]types.ImageDelete, error) // Return all containers Containers() Containers // Start a container StartContainer(container *Container, hostConfig *dockerclient.HostConfig) error // Return container the matching `IDOrName` // TODO: remove this method from the interface as we can use // cluster.Containers().Get(IDOrName) Container(IDOrName string) *Container // Return all networks Networks() Networks // Create a network CreateNetwork(name string, request *types.NetworkCreate) (*types.NetworkCreateResponse, error) // Remove a network from the cluster RemoveNetwork(network *Network) error // Create a volume CreateVolume(request *volume.VolumesCreateBody) (*types.Volume, error) // Return all volumes Volumes() Volumes // Remove volumes from the cluster RemoveVolumes(name string) (bool, error) // Pull images // `callback` can be called multiple time // `where` is where it is being pulled // `status` is the current status, like "", "in progress" or "downloaded" Pull(name string, authConfig *types.AuthConfig, callback func(where, status string, err error)) // Import image // `callback` can be called multiple time // `where` is where it is being imported // `status` is the current status, like "", "in progress" or "imported" Import(source string, ref string, tag string, imageReader io.Reader, callback func(where, status string, err error)) // Load images // `callback` can be called multiple time // `what` is what is being loaded // `status` is the current status, like "", "in progress" or "loaded" Load(imageReader io.Reader, callback func(what, status string, err error)) // Return some info about the cluster, like nb of containers / images // It is pretty open, so the implementation decides what to return. Info() [][2]string // Return the total memory of the cluster TotalMemory() int64 // Return the number of CPUs in the cluster TotalCpus() int64 // Register an event handler for cluster-wide events. RegisterEventHandler(h EventHandler) error // Unregister an event handler. UnregisterEventHandler(h EventHandler) // FIXME: remove this method // Return a random engine RANDOMENGINE() (*Engine, error) // Rename a container RenameContainer(container *Container, newName string) error // Build an image BuildImage(io.Reader, *types.ImageBuildOptions, io.Writer) error // Tag an image TagImage(IDOrName string, ref string, force bool) error }
Cluster is exported
type Container ¶
type Container struct { types.Container Config *ContainerConfig Info types.ContainerJSON Engine *Engine }
Container is exported
type ContainerConfig ¶ added in v0.3.0
type ContainerConfig struct { container.Config HostConfig container.HostConfig NetworkingConfig network.NetworkingConfig }
ContainerConfig is exported TODO store affinities and constraints in their own fields
func BuildContainerConfig ¶ added in v0.3.0
func BuildContainerConfig(c container.Config, h container.HostConfig, n network.NetworkingConfig) *ContainerConfig
BuildContainerConfig creates a cluster.ContainerConfig from a Config, HostConfig, and NetworkingConfig
func (*ContainerConfig) AddAffinity ¶ added in v0.4.0
func (c *ContainerConfig) AddAffinity(affinity string) error
AddAffinity to config
func (*ContainerConfig) AddConstraint ¶ added in v1.1.3
func (c *ContainerConfig) AddConstraint(constraint string) error
AddConstraint to config
func (*ContainerConfig) Affinities ¶ added in v0.3.0
func (c *ContainerConfig) Affinities() []string
Affinities returns all the affinities from the ContainerConfig
func (*ContainerConfig) Constraints ¶ added in v0.3.0
func (c *ContainerConfig) Constraints() []string
Constraints returns all the constraints from the ContainerConfig
func (*ContainerConfig) HasReschedulePolicy ¶ added in v1.1.0
func (c *ContainerConfig) HasReschedulePolicy(p string) bool
HasReschedulePolicy returns true if the specified policy is part of the config
func (*ContainerConfig) HaveNodeConstraint ¶ added in v1.0.0
func (c *ContainerConfig) HaveNodeConstraint() bool
HaveNodeConstraint in config
func (*ContainerConfig) RemoveAffinity ¶ added in v1.1.0
func (c *ContainerConfig) RemoveAffinity(affinity string) error
RemoveAffinity from config
func (*ContainerConfig) SetSwarmID ¶ added in v0.3.0
func (c *ContainerConfig) SetSwarmID(id string)
SetSwarmID sets or overrides the Swarm ID in the Config.
func (*ContainerConfig) SwarmID ¶ added in v0.3.0
func (c *ContainerConfig) SwarmID() string
SwarmID extracts the Swarm ID from the Config. May return an empty string if not set.
func (*ContainerConfig) Validate ¶ added in v1.1.0
func (c *ContainerConfig) Validate() error
Validate returns an error if the config isn't valid
type Containers ¶ added in v0.3.0
type Containers []*Container
Containers represents a list of containers
func (Containers) Get ¶ added in v0.3.0
func (containers Containers) Get(IDOrName string) *Container
Get returns a container using its ID or Name
type DriverOpts ¶ added in v0.3.0
type DriverOpts []string
DriverOpts are key=values options
func (DriverOpts) Bool ¶ added in v1.1.0
func (do DriverOpts) Bool(key, env string) (bool, bool)
Bool returns a boolean from the driver options
func (DriverOpts) Float ¶ added in v0.3.0
func (do DriverOpts) Float(key, env string) (float64, bool)
Float returns a float64 from the driver options
func (DriverOpts) IP ¶ added in v0.3.0
func (do DriverOpts) IP(key, env string) (net.IP, bool)
IP returns an IP address from the driver options
func (DriverOpts) Int ¶ added in v0.3.0
func (do DriverOpts) Int(key, env string) (int64, bool)
Int returns an int64 from the driver options
type Engine ¶ added in v0.3.0
type Engine struct { sync.RWMutex ID string IP string Addr string Name string Cpus int64 Memory int64 Labels map[string]string Version string DeltaDuration time.Duration // swarm's systime - engine's systime // contains filtered or unexported fields }
Engine represents a docker engine
func NewEngine ¶ added in v0.3.0
func NewEngine(addr string, overcommitRatio float64, opts *EngineOpts) *Engine
NewEngine is exported
func (*Engine) AddContainer ¶ added in v0.3.0
AddContainer injects a container into the internal state.
func (*Engine) AddNetwork ¶ added in v1.1.1
AddNetwork adds a network to the internal engine state.
func (*Engine) BuildImage ¶ added in v0.4.0
func (e *Engine) BuildImage(buildContext io.Reader, buildImage *types.ImageBuildOptions) (io.ReadCloser, error)
BuildImage builds an image
func (*Engine) CheckConnectionErr ¶ added in v1.1.0
CheckConnectionErr checks error from client response and adjusts engine healthy indicators
func (*Engine) Connect ¶ added in v0.3.0
Connect will initialize a connection to the Docker daemon running on the host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (*Engine) ConnectWithClient ¶ added in v0.3.0
func (e *Engine) ConnectWithClient(client dockerclient.Client, apiClient swarmclient.SwarmAPIClient) error
ConnectWithClient is exported
func (*Engine) Containers ¶ added in v0.3.0
func (e *Engine) Containers() Containers
Containers returns all the containers in the engine.
func (*Engine) CreateContainer ¶ added in v1.2.4
func (e *Engine) CreateContainer(config *ContainerConfig, name string, pullImage bool, authConfig *types.AuthConfig) (*Container, error)
CreateContainer creates a new container
func (*Engine) CreateNetwork ¶ added in v1.0.0
func (e *Engine) CreateNetwork(name string, request *types.NetworkCreate) (*types.NetworkCreateResponse, error)
CreateNetwork creates a network in the engine
func (*Engine) CreateVolume ¶ added in v1.0.0
CreateVolume creates a volume in the engine
func (*Engine) DeleteNetwork ¶ added in v1.1.1
DeleteNetwork deletes a network from the internal engine state.
func (*Engine) Disconnect ¶ added in v0.3.0
func (e *Engine) Disconnect()
Disconnect will stop all monitoring of the engine. The Engine object cannot be further used without reconnecting it first.
func (*Engine) HTTPClientAndScheme ¶ added in v1.1.1
HTTPClientAndScheme returns the underlying HTTPClient and the scheme used by the engine
func (*Engine) HandleIDConflict ¶ added in v1.1.0
HandleIDConflict handles ID duplicate with existing engine
func (*Engine) HealthIndicator ¶ added in v1.1.0
HealthIndicator returns degree of healthiness between 0 and 100. 0 means node is not healthy (unhealthy, pending), 100 means last connectivity was successful other values indicate recent failures but haven't moved engine out of healthy state
func (*Engine) Pull ¶ added in v0.3.0
func (e *Engine) Pull(image string, authConfig *types.AuthConfig) error
Pull an image on the engine
func (*Engine) RefreshContainers ¶ added in v0.3.0
RefreshContainers will refresh the list and status of containers running on the engine. If `full` is true, each container will be inspected. FIXME: unexport this method after mesos scheduler stops using it directly
func (*Engine) RefreshImages ¶ added in v0.3.0
RefreshImages refreshes the list of images on the engine.
func (*Engine) RefreshNetworks ¶ added in v1.0.0
RefreshNetworks refreshes the list of networks on the engine.
func (*Engine) RefreshVolumes ¶ added in v1.0.0
RefreshVolumes refreshes the list of volumes on the engine.
func (*Engine) RegisterEventHandler ¶ added in v0.3.0
func (e *Engine) RegisterEventHandler(h EventHandler) error
RegisterEventHandler registers an event handler.
func (*Engine) RemoveContainer ¶ added in v0.3.0
RemoveContainer removes a container from the engine.
func (*Engine) RemoveImage ¶ added in v0.3.0
RemoveImage deletes an image from the engine.
func (*Engine) RemoveNetwork ¶ added in v1.0.0
RemoveNetwork removes a network from the engine.
func (*Engine) RemoveVolume ¶ added in v1.0.0
RemoveVolume deletes a volume from the engine.
func (*Engine) RenameContainer ¶ added in v0.3.0
RenameContainer renames a container
func (*Engine) StartContainer ¶ added in v1.1.0
func (e *Engine) StartContainer(id string, hostConfig *dockerclient.HostConfig) error
StartContainer starts a container
func (*Engine) StartMonitorEvents ¶ added in v1.1.0
func (e *Engine) StartMonitorEvents()
StartMonitorEvents monitors events from the engine
func (*Engine) Status ¶ added in v1.0.1
Status returns the health status of the Engine: Healthy or Unhealthy
func (*Engine) TimeToValidate ¶ added in v1.1.0
TimeToValidate returns true if a pending node is up for validation
func (*Engine) TotalMemory ¶ added in v0.3.0
TotalMemory returns the total memory + overcommit
func (*Engine) UsedMemory ¶ added in v0.3.0
UsedMemory returns the sum of memory reserved by containers.
func (*Engine) ValidationComplete ¶ added in v1.1.0
func (e *Engine) ValidationComplete()
ValidationComplete transitions engine state from statePending to stateHealthy
type EngineOpts ¶ added in v1.0.1
type EngineOpts struct { RefreshMinInterval time.Duration RefreshMaxInterval time.Duration FailureRetry int }
EngineOpts represents the options for an engine
type EngineSorter ¶ added in v0.3.0
type EngineSorter []*Engine
EngineSorter implements the Sort interface to sort Cluster.Engine. It is not guaranteed to be a stable sort.
func (EngineSorter) Len ¶ added in v0.3.0
func (s EngineSorter) Len() int
Len returns the number of engines to be sorted.
func (EngineSorter) Less ¶ added in v0.3.0
func (s EngineSorter) Less(i, j int) bool
Less reports whether the engine with index i should sort before the engine with index j. Engines are sorted chronologically by name.
func (EngineSorter) Swap ¶ added in v0.3.0
func (s EngineSorter) Swap(i, j int)
Swap exchanges the engine elements with indices i and j.
type EventHandlers ¶ added in v1.1.0
EventHandlers is a map of EventHandler
func NewEventHandlers ¶ added in v1.1.0
func NewEventHandlers() *EventHandlers
NewEventHandlers returns an EventHandlers
func (*EventHandlers) Handle ¶ added in v1.1.0
func (eh *EventHandlers) Handle(e *Event)
Handle callbacks for the events
func (*EventHandlers) RegisterEventHandler ¶ added in v1.1.0
func (eh *EventHandlers) RegisterEventHandler(h EventHandler) error
RegisterEventHandler registers an event handler.
func (*EventHandlers) UnregisterEventHandler ¶ added in v1.1.0
func (eh *EventHandlers) UnregisterEventHandler(h EventHandler)
UnregisterEventHandler unregisters a previously registered event handler.
type EventsMonitor ¶ added in v1.2.1
type EventsMonitor struct {
// contains filtered or unexported fields
}
EventsMonitor monitors events
func NewEventsMonitor ¶ added in v1.2.1
func NewEventsMonitor(cli swarmclient.SwarmAPIClient, handler func(msg events.Message) error) *EventsMonitor
NewEventsMonitor returns an EventsMonitor
func (*EventsMonitor) Start ¶ added in v1.2.1
func (em *EventsMonitor) Start(ec chan error)
Start starts the EventsMonitor
func (*EventsMonitor) Stop ¶ added in v1.2.1
func (em *EventsMonitor) Stop()
Stop stops the EventsMonitor
type Image ¶ added in v0.2.0
type Image struct { types.ImageSummary Engine *Engine }
Image is exported
type ImageFilterOptions ¶ added in v1.0.0
type ImageFilterOptions struct {
types.ImageListOptions
}
ImageFilterOptions is the set of filtering options supported by Images.Filter()
type Images ¶ added in v1.0.0
type Images []*Image
Images is a collection of Image objects that can be filtered
func (Images) Filter ¶ added in v1.0.0
func (images Images) Filter(opts ImageFilterOptions) Images
Filter returns a new sequence of Images filtered to only the images that matched the filtering parameters
type Network ¶ added in v1.0.0
type Network struct { types.NetworkResource Engine *Engine }
Network is exported
func (*Network) RemoveDuplicateEndpoints ¶ added in v1.2.0
RemoveDuplicateEndpoints returns a copy of input network where duplicate container endpoints in the network are removed. See https://github.com/docker/swarm/issues/1969 This function should be disabled when the bug is fixed in Docker network
type Networks ¶ added in v1.0.0
type Networks []*Network
Networks represents an array of networks
type OldContainerConfig ¶ added in v1.2.1
type OldContainerConfig struct { ContainerConfig Memory int64 MemorySwap int64 CPUSet string `json:"Cpuset"` }
OldContainerConfig contains additional fields for backward compatibility This should be removed after we stop supporting API versions <= 1.8
type Watchdog ¶ added in v1.1.0
Watchdog listens to cluster events and handles container rescheduling
func NewWatchdog ¶ added in v1.1.0
NewWatchdog creates a new watchdog