Documentation
¶
Index ¶
- Constants
- Variables
- func GenVolumeSourceForSwarm(source string) string
- func GenVolumeSourceName(source string, memberName string) string
- func GetServiceJournalVolumeName(serviceUUID string) string
- type CommonOptions
- type ContainerSvc
- type CreateServiceOptions
- type Info
- type MemContainerSvc
- func (m *MemContainerSvc) AddServiceTask(ctx context.Context, cluster string, service string, taskID string, ...) error
- func (m *MemContainerSvc) CreateService(ctx context.Context, opts *CreateServiceOptions) error
- func (m *MemContainerSvc) CreateServiceVolume(ctx context.Context, service string, memberName string, volumeID string, ...) (existingVolumeID string, err error)
- func (m *MemContainerSvc) DeleteService(ctx context.Context, cluster string, service string) error
- func (m *MemContainerSvc) DeleteServiceVolume(ctx context.Context, service string, memberName string, journal bool) error
- func (m *MemContainerSvc) DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
- func (m *MemContainerSvc) GetContainerSvcType() string
- func (m *MemContainerSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
- func (m *MemContainerSvc) GetServiceTask(ctx context.Context, cluster string, service string, ...) (taskID string, err error)
- func (m *MemContainerSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
- func (m *MemContainerSvc) IsServiceExist(ctx context.Context, cluster string, service string) (bool, error)
- func (m *MemContainerSvc) ListActiveServiceTasks(ctx context.Context, cluster string, service string) (taskIDs map[string]bool, err error)
- func (m *MemContainerSvc) RollingRestartService(ctx context.Context, cluster string, service string, ...) error
- func (m *MemContainerSvc) RunTask(ctx context.Context, opts *RunTaskOptions) (taskID string, err error)
- func (m *MemContainerSvc) ScaleService(ctx context.Context, cluster string, service string, desiredCount int64) error
- func (m *MemContainerSvc) StopService(ctx context.Context, cluster string, service string) error
- func (m *MemContainerSvc) UpdateService(ctx context.Context, opts *UpdateServiceOptions) error
- type MockContainerSvcInfo
- type Placement
- type RollingRestartOptions
- type RunTaskOptions
- type UpdateServiceOptions
- type VolumeOptions
Constants ¶
View Source
const ( // The journal volume name prefix, the journal volume name will be journal-serviceuuid, // the mount path will be /mnt/journal-serviceuuid JournalVolumeNamePrefix = "journal" // TestBusyBoxContainerImage is the busybox image for unit test. TestBusyBoxContainerImage = common.OrgName + common.SystemName + "-busybox" )
Variables ¶
View Source
var ( ErrContainerSvcTooManyTasks = errors.New("The service has more than one tasks on the same ContainerInstance") ErrContainerSvcNoTask = errors.New("The service has no task on the ContainerInstance") ErrInvalidContainerInstanceID = errors.New("InvalidContainerInstanceID") ErrInvalidCluster = errors.New("InvalidCluster") ErrVolumeExist = errors.New("Volume Exists") )
Functions ¶
func GenVolumeSourceForSwarm ¶
GenVolumeSourceForSwarm creates the volume mount source for swarm service. https://docs.docker.com/docker-for-aws/persistent-data-volumes/#use-a-unique-volume-per-task-using-ebs. so the volume driver could directly know which volume to mount.
func GenVolumeSourceName ¶
GenVolumeSourceName creates the volume source name.
func GetServiceJournalVolumeName ¶ added in v0.9.6
GetServiceJournalVolumeName adds the volume name prefix
Types ¶
type CommonOptions ¶
type ContainerSvc ¶
type ContainerSvc interface {
// GetContainerSvcType gets the containersvc type, such as ecs, swarm, k8s.
GetContainerSvcType() string
// IsServiceExist checks if service exists. If not exist, return false & nil. If exists, return true & nil.
// If meets any error, error will be returned.
IsServiceExist(ctx context.Context, cluster string, service string) (bool, error)
CreateService(ctx context.Context, opts *CreateServiceOptions) error
UpdateService(ctx context.Context, opts *UpdateServiceOptions) error
GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
// StopService stops the service on the container platform, and waits till all containers are stopped.
// Expect no error (nil) if service is already stopped or does not exist.
StopService(ctx context.Context, cluster string, service string) error
// ScaleService scales the service containers up/down to the desiredCount. Note: it does not wait till all containers are started or stopped.
ScaleService(ctx context.Context, cluster string, service string, desiredCount int64) error
// DeleteService deletes the service on the container platform.
// Expect no error (nil) if service does not exist.
DeleteService(ctx context.Context, cluster string, service string) error
// RollingRestartService restarts the tasks one after the other.
RollingRestartService(ctx context.Context, cluster string, service string, opts *RollingRestartOptions) error
// List the active (pending and running) tasks of the service.
ListActiveServiceTasks(ctx context.Context, cluster string, service string) (serviceTaskIDs map[string]bool, err error)
GetServiceTask(ctx context.Context, cluster string, service string, containerInstanceID string) (serviceTaskID string, err error)
// One node (EC2) could crash at any time. So the task needs to be reentrant.
// The container orchestration framework, such as ECS, usually does not retry the
// task automatically, when a taks fails. The caller needs to check the task status
// and decide whether to retry.
// It may not be easy to know the task failure reason clearly.
// For example, ECS task will reach the stopped status at many conditions,
// http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_life_cycle.html.
// The Task.StoppedReason records the detail reason,
// http://docs.aws.amazon.com/AmazonECS/latest/developerguide/troubleshooting.html#stopped-task-errors.
//
// The caller could check whether a task succeeds or not by checking
// both TaskStatus.Status and TaskStatus.StoppedReason. This does not sounds the best
// option. It would be better that ECS could add the explicit task failure status.
//
// The other option is the task updates the status somewhere at the end,
// and the caller could check that status to decide whether the task needs to be retried.
// For example, the MongoDB init task will set the service initialized in the control plane.
RunTask(ctx context.Context, opts *RunTaskOptions) (taskID string, err error)
GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
// Create the service volume. This is only useful for k8s to create PV and PVC. And simply non-op for ECS and Swarm.
CreateServiceVolume(ctx context.Context, service string, memberName string, volumeID string, volumeSizeGB int64, journal bool) (existingVolumeID string, err error)
DeleteServiceVolume(ctx context.Context, service string, memberName string, journal bool) error
}
ContainerSvc defines the cluster, service and task related functions
type CreateServiceOptions ¶
type CreateServiceOptions struct {
Replicas int64
Common *CommonOptions
// PortMappings include the ports exposed by the services. It includes a "ServicePort" field
// for whether the port is a service port, used by k8s headless service for statefulset.
// https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#creating-a-statefulset
// https://kubernetes.io/docs/concepts/services-networking/service/#headless-services
// https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services
PortMappings []common.PortMapping
// the placement constraints. If not specified, spread to all zones.
Place *Placement
Envkvs []*common.EnvKeyValuePair
// The volume mount for the service data, must exist.
DataVolume *VolumeOptions
// The volume mount for the service journal, optional.
JournalVolume *VolumeOptions
// Whether uses external DNS. For example, set to true if connect with AWS Route53.
// If only use within k8s, set to false.
ExternalDNS bool
// Whether uses the external static IP. This is only for the services that require static ip, such as Redis, Consul.
ExternalStaticIP bool
}
type MemContainerSvc ¶
type MemContainerSvc struct {
// contains filtered or unexported fields
}
func NewMemContainerSvc ¶
func NewMemContainerSvc() *MemContainerSvc
func (*MemContainerSvc) AddServiceTask ¶
func (*MemContainerSvc) CreateService ¶
func (m *MemContainerSvc) CreateService(ctx context.Context, opts *CreateServiceOptions) error
func (*MemContainerSvc) CreateServiceVolume ¶ added in v0.9.3
func (*MemContainerSvc) DeleteService ¶
func (*MemContainerSvc) DeleteServiceVolume ¶ added in v0.9.3
func (*MemContainerSvc) DeleteTask ¶
func (*MemContainerSvc) GetContainerSvcType ¶ added in v0.9.3
func (m *MemContainerSvc) GetContainerSvcType() string
func (*MemContainerSvc) GetServiceStatus ¶
func (m *MemContainerSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
func (*MemContainerSvc) GetServiceTask ¶
func (*MemContainerSvc) GetTaskStatus ¶
func (m *MemContainerSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
func (*MemContainerSvc) IsServiceExist ¶
func (*MemContainerSvc) ListActiveServiceTasks ¶
func (*MemContainerSvc) RollingRestartService ¶ added in v0.9.4
func (m *MemContainerSvc) RollingRestartService(ctx context.Context, cluster string, service string, opts *RollingRestartOptions) error
func (*MemContainerSvc) RunTask ¶
func (m *MemContainerSvc) RunTask(ctx context.Context, opts *RunTaskOptions) (taskID string, err error)
func (*MemContainerSvc) ScaleService ¶ added in v0.9.2
func (*MemContainerSvc) StopService ¶
func (*MemContainerSvc) UpdateService ¶ added in v0.9.5
func (m *MemContainerSvc) UpdateService(ctx context.Context, opts *UpdateServiceOptions) error
type MockContainerSvcInfo ¶
type MockContainerSvcInfo struct {
}
func NewMockContainerSvcInfo ¶
func NewMockContainerSvcInfo() *MockContainerSvcInfo
func (*MockContainerSvcInfo) GetContainerClusterID ¶
func (m *MockContainerSvcInfo) GetContainerClusterID() string
func (*MockContainerSvcInfo) GetLocalContainerInstanceID ¶
func (m *MockContainerSvcInfo) GetLocalContainerInstanceID() string
type RollingRestartOptions ¶ added in v0.9.4
type RunTaskOptions ¶
type RunTaskOptions struct {
Common *CommonOptions
TaskType string
Envkvs []*common.EnvKeyValuePair
}
type UpdateServiceOptions ¶ added in v0.9.5
type UpdateServiceOptions struct {
Cluster string
ServiceName string
// update cpu and memory limits
MaxCPUUnits *int64
ReserveCPUUnits *int64
MaxMemMB *int64
ReserveMemMB *int64
// update port mappings
PortMappings []common.PortMapping
// Whether uses external DNS. For example, set to true if connect with AWS Route53.
// If only use within k8s, set to false.
ExternalDNS bool
// update the release version, such as 0.9.5. empty means no change.
ReleaseVersion string
}
Directories
¶
| Path | Synopsis |
|---|---|
|
firecamp-initcontainer
command
|
|
|
firecamp-stopcontainer
command
|
|
|
k8s-test
command
Note: the example only works with the code within the same release/branch.
|
Note: the example only works with the code within the same release/branch. |
|
test
command
|
Click to show internal directories.
Click to hide internal directories.