Documentation ¶
Index ¶
- type SwarmClient
- type SwarmInfo
- type SwarmSvc
- func (s *SwarmSvc) CreateService(ctx context.Context, opts *containersvc.CreateServiceOptions) error
- func (s *SwarmSvc) CreateServiceSpec(opts *containersvc.CreateServiceOptions) swarm.ServiceSpec
- func (s *SwarmSvc) CreateServiceVolume(ctx context.Context, service string, memberName string, volumeID string, ...) (existingVolumeID string, err error)
- func (s *SwarmSvc) CreateSwarmService(ctx context.Context, serviceSpec swarm.ServiceSpec, ...) error
- func (s *SwarmSvc) DeleteService(ctx context.Context, cluster string, service string) error
- func (s *SwarmSvc) DeleteServiceVolume(ctx context.Context, service string, memberName string, journal bool) error
- func (s *SwarmSvc) DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
- func (s *SwarmSvc) GetContainerSvcType() string
- func (s *SwarmSvc) GetJoinToken(ctx context.Context) (managerToken string, workerToken string, err error)
- func (s *SwarmSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
- func (s *SwarmSvc) GetServiceTask(ctx context.Context, cluster string, service string, ...) (serviceTaskID string, err error)
- func (s *SwarmSvc) GetTaskContainerInstance(ctx context.Context, cluster string, serviceTaskID string) (containerInstanceID string, err error)
- func (s *SwarmSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
- func (s *SwarmSvc) IsServiceExist(ctx context.Context, cluster string, service string) (bool, error)
- func (s *SwarmSvc) IsSwarmInitialized(ctx context.Context) (bool, error)
- func (s *SwarmSvc) ListActiveServiceTasks(ctx context.Context, cluster string, service string) (serviceTaskIDs map[string]bool, err error)
- func (s *SwarmSvc) ListSwarmManagerNodes(ctx context.Context) (goodManagers []string, downManagerNodes []swarm.Node, downManagers []string, ...)
- func (s *SwarmSvc) RemoveDownManagerNode(ctx context.Context, node swarm.Node) error
- func (s *SwarmSvc) RollingRestartService(ctx context.Context, cluster string, service string, ...) error
- func (s *SwarmSvc) RunTask(ctx context.Context, opts *containersvc.RunTaskOptions) (taskID string, err error)
- func (s *SwarmSvc) ScaleService(ctx context.Context, cluster string, service string, desiredCount int64) error
- func (s *SwarmSvc) StopService(ctx context.Context, cluster string, service string) error
- func (s *SwarmSvc) SwarmInit(ctx context.Context, addr string) error
- func (s *SwarmSvc) SwarmJoin(ctx context.Context, addr string, joinAddr string, token string) error
- func (s *SwarmSvc) UpdateService(ctx context.Context, opts *containersvc.UpdateServiceOptions) error
- func (s *SwarmSvc) WaitServiceRunning(ctx context.Context, cluster string, service string, replicas int64, ...) error
- func (s *SwarmSvc) WaitTaskComplete(ctx context.Context, cluster string, taskID string, maxWaitSeconds int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SwarmClient ¶
type SwarmClient struct {
// contains filtered or unexported fields
}
func NewSwarmClient ¶
func NewSwarmClient() (*SwarmClient, error)
NewSwarmClient creates a new SwarmClient instance
type SwarmInfo ¶
type SwarmInfo struct {
// contains filtered or unexported fields
}
func NewSwarmInfo ¶
func (*SwarmInfo) GetContainerClusterID ¶
func (*SwarmInfo) GetLocalContainerInstanceID ¶
type SwarmSvc ¶
type SwarmSvc struct {
// contains filtered or unexported fields
}
SwarmSvc implements swarm service and task related functions.
TODO task framework on Swarm. Swarm doesn't support the task execution. The SwarmSvc will have to manage the task lifecycle. The Docker daemon on the swarm worker node will have to listen on the host port, so docker API could be accessed remotely. The SwarmSvc will periodically collect the metrics, select one node, store it in db. If the node is full, select another node to run the task. At v1, the task is simply run on the swarm manager node. This is not a big issue, as the task would usually run some simple job, such as setup the MongoDB ReplicaSet.
func NewSwarmSvcOnManagerNode ¶ added in v0.9.5
NewSwarmSvcOnManagerNode creates a new SwarmSvc instance on the manager node
func NewSwarmSvcOnWorkerNode ¶ added in v0.9.5
NewSwarmSvcOnWorkerNode creates a new SwarmSvc instance on the worker node for such as volume plugin.
func (*SwarmSvc) CreateService ¶
func (s *SwarmSvc) CreateService(ctx context.Context, opts *containersvc.CreateServiceOptions) error
CreateService creates a swarm service
func (*SwarmSvc) CreateServiceSpec ¶
func (s *SwarmSvc) CreateServiceSpec(opts *containersvc.CreateServiceOptions) swarm.ServiceSpec
CreateServiceSpec creates the swarm ServiceSpec.
func (*SwarmSvc) CreateServiceVolume ¶ added in v0.9.3
func (s *SwarmSvc) CreateServiceVolume(ctx context.Context, service string, memberName string, volumeID string, volumeSizeGB int64, journal bool) (existingVolumeID string, err error)
CreateServiceVolume is a non-op for swarm.
func (*SwarmSvc) CreateSwarmService ¶
func (s *SwarmSvc) CreateSwarmService(ctx context.Context, serviceSpec swarm.ServiceSpec, opts *containersvc.CreateServiceOptions) error
CreateSwarmService creates the swarm service.
func (*SwarmSvc) DeleteService ¶
DeleteService delets a swarm service
func (*SwarmSvc) DeleteServiceVolume ¶ added in v0.9.3
func (s *SwarmSvc) DeleteServiceVolume(ctx context.Context, service string, memberName string, journal bool) error
DeleteServiceVolume is a non-op for swarm.
func (*SwarmSvc) DeleteTask ¶
func (s *SwarmSvc) DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
DeleteTask deletes the task container
func (*SwarmSvc) GetContainerSvcType ¶ added in v0.9.3
GetContainerSvcType gets the containersvc type.
func (*SwarmSvc) GetJoinToken ¶
func (s *SwarmSvc) GetJoinToken(ctx context.Context) (managerToken string, workerToken string, err error)
GetJoinToken gets the swarm manager and worker node join token.
func (*SwarmSvc) GetServiceStatus ¶
func (s *SwarmSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
GetServiceStatus gets the service's status.
func (*SwarmSvc) GetServiceTask ¶
func (s *SwarmSvc) GetServiceTask(ctx context.Context, cluster string, service string, containerInstanceID string) (serviceTaskID string, err error)
GetServiceTask gets the task running on the containerInstanceID
func (*SwarmSvc) GetTaskContainerInstance ¶
func (s *SwarmSvc) GetTaskContainerInstance(ctx context.Context, cluster string, serviceTaskID string) (containerInstanceID string, err error)
GetTaskContainerInstance returns the ContainerInstanceID the task runs on
func (*SwarmSvc) GetTaskStatus ¶
func (s *SwarmSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
GetTaskStatus returns the task's status.
func (*SwarmSvc) IsServiceExist ¶
func (s *SwarmSvc) IsServiceExist(ctx context.Context, cluster string, service string) (bool, error)
IsServiceExist checks whether the service exists
func (*SwarmSvc) IsSwarmInitialized ¶
IsSwarmInitialized checks if the swarm cluster is initialized.
func (*SwarmSvc) ListActiveServiceTasks ¶
func (s *SwarmSvc) ListActiveServiceTasks(ctx context.Context, cluster string, service string) (serviceTaskIDs map[string]bool, err error)
ListActiveServiceTasks lists the active (running and pending) tasks of the service
func (*SwarmSvc) ListSwarmManagerNodes ¶ added in v0.9.4
func (s *SwarmSvc) ListSwarmManagerNodes(ctx context.Context) (goodManagers []string, downManagerNodes []swarm.Node, downManagers []string, err error)
ListSwarmManagerNodes returns the good and down managers
func (*SwarmSvc) RemoveDownManagerNode ¶ added in v0.9.4
RemoveDownManagerNode removes the down manager node.
func (*SwarmSvc) RollingRestartService ¶ added in v0.9.4
func (s *SwarmSvc) RollingRestartService(ctx context.Context, cluster string, service string, opts *containersvc.RollingRestartOptions) error
RollingRestartService restarts the service tasks one after the other.
func (*SwarmSvc) RunTask ¶
func (s *SwarmSvc) RunTask(ctx context.Context, opts *containersvc.RunTaskOptions) (taskID string, err error)
RunTask creates and runs the task once. It does 3 steps: 1) pull the image, 2) create the container, 3) start the container.
func (*SwarmSvc) ScaleService ¶ added in v0.9.2
func (s *SwarmSvc) ScaleService(ctx context.Context, cluster string, service string, desiredCount int64) error
ScaleService scales the service containers up/down to the desiredCount.
func (*SwarmSvc) StopService ¶
StopService stops all service containers
func (*SwarmSvc) UpdateService ¶ added in v0.9.5
func (s *SwarmSvc) UpdateService(ctx context.Context, opts *containersvc.UpdateServiceOptions) error
UpdateService updates the service