Documentation
¶
Index ¶
- func GenerateServiceName(image string) (string, error)
- type Client
- type ContainerSpecStatus
- type CreateVolumeOperation
- type Deployment
- type NameResolver
- type Operation
- type Plan
- type RemoveContainerOperation
- type RollingStrategy
- type RunContainerOperation
- type SequenceOperation
- type ServiceSpecResolver
- type StopContainerOperation
- type Strategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateServiceName ¶ added in v0.6.0
Types ¶
type Client ¶
type Client interface {
api.ContainerClient
api.DNSClient
api.ImageClient
api.MachineClient
api.ServiceClient
api.VolumeClient
}
type ContainerSpecStatus ¶
type ContainerSpecStatus string
const ( ContainerUpToDate ContainerSpecStatus = "up-to-date" ContainerNeedsUpdate ContainerSpecStatus = "needs-update" ContainerNeedsRecreate ContainerSpecStatus = "needs-recreate" )
func EvalContainerSpecChange ¶
func EvalContainerSpecChange(current api.ServiceSpec, new api.ServiceSpec) ContainerSpecStatus
type CreateVolumeOperation ¶ added in v0.6.0
type CreateVolumeOperation struct {
VolumeSpec api.VolumeSpec
MachineID string
// MachineName is used for formatting the operation output only.
MachineName string
}
CreateVolumeOperation creates a volume on a specific machine.
func (*CreateVolumeOperation) Execute ¶ added in v0.6.0
func (o *CreateVolumeOperation) Execute(ctx context.Context, cli Client) error
func (*CreateVolumeOperation) Format ¶ added in v0.6.0
func (o *CreateVolumeOperation) Format(_ NameResolver) string
func (*CreateVolumeOperation) String ¶ added in v0.6.0
func (o *CreateVolumeOperation) String() string
type Deployment ¶
type Deployment struct {
Service *api.Service
Spec api.ServiceSpec
Strategy Strategy
// contains filtered or unexported fields
}
Deployment manages the process of creating or updating a service to match a desired state. It coordinates the validation, planning, and execution of deployment operations.
func NewDeployment ¶
func NewDeployment(cli Client, spec api.ServiceSpec, strategy Strategy) *Deployment
NewDeployment creates a new deployment for the given service specification. If strategy is nil, a default RollingStrategy will be used.
func NewDeploymentWithClusterState ¶ added in v0.15.0
func NewDeploymentWithClusterState( cli Client, spec api.ServiceSpec, strategy Strategy, state *scheduler.ClusterState, ) *Deployment
NewDeploymentWithClusterState creates a new deployment like NewDeployment but also with a provided current cluster state used for scheduling decisions.
func (*Deployment) Plan ¶
func (d *Deployment) Plan(ctx context.Context) (Plan, error)
Plan returns a plan of operations to reconcile the service to the desired state. If a plan has already been created, the same plan will be returned.
func (*Deployment) Run ¶
func (d *Deployment) Run(ctx context.Context) (Plan, error)
Run executes the deployment plan and returns the ID of the created or updated service. It will create a new plan if one hasn't been created yet. The deployment will either create a new service or update the existing one to match the desired specification. TODO: forbid to run the same deployment more than once.
type NameResolver ¶
type NameResolver interface {
MachineName(machineID string) string
ContainerName(containerID string) string
}
NameResolver resolves machine and container IDs to their names.
type Operation ¶
type Operation interface {
// Execute performs the operation using the provided client.
// TODO: Encapsulate the client in the operation as otherwise it gives an impression that different clients
// can be provided. But in reality, the operation is tightly coupled with the client that was used to create it.
Execute(ctx context.Context, cli Client) error
// Format returns a human-readable representation of the operation.
// TODO: get rid of the resolver and assign the required names for formatting in the operation itself.
Format(resolver NameResolver) string
String() string
}
Operation represents a single atomic operation in a deployment process. Operations can be composed to form complex deployment strategies.
type Plan ¶
type Plan struct {
ServiceID string
ServiceName string
SequenceOperation
}
type RemoveContainerOperation ¶
type RemoveContainerOperation struct {
MachineID string
Container api.ServiceContainer
}
RemoveContainerOperation stops and removes a container from a specific machine.
func (*RemoveContainerOperation) Execute ¶
func (o *RemoveContainerOperation) Execute(ctx context.Context, cli Client) error
func (*RemoveContainerOperation) Format ¶
func (o *RemoveContainerOperation) Format(resolver NameResolver) string
func (*RemoveContainerOperation) String ¶
func (o *RemoveContainerOperation) String() string
type RollingStrategy ¶
type RollingStrategy struct {
// ForceRecreate indicates whether all containers should be recreated during the deployment,
// regardless of whether their specifications have changed.
ForceRecreate bool
// contains filtered or unexported fields
}
RollingStrategy implements a rolling update deployment pattern where containers are updated one at a time to minimize service disruption.
func (*RollingStrategy) Plan ¶
func (s *RollingStrategy) Plan(state *scheduler.ClusterState, svc *api.Service, spec api.ServiceSpec) (Plan, error)
func (*RollingStrategy) Type ¶
func (s *RollingStrategy) Type() string
type RunContainerOperation ¶
type RunContainerOperation struct {
ServiceID string
Spec api.ServiceSpec
MachineID string
}
RunContainerOperation creates and starts a new container on a specific machine.
func (*RunContainerOperation) Execute ¶
func (o *RunContainerOperation) Execute(ctx context.Context, cli Client) error
func (*RunContainerOperation) Format ¶
func (o *RunContainerOperation) Format(resolver NameResolver) string
func (*RunContainerOperation) String ¶
func (o *RunContainerOperation) String() string
type SequenceOperation ¶
type SequenceOperation struct {
Operations []Operation
}
SequenceOperation is a composite operation that executes a sequence of operations in order.
func (*SequenceOperation) Execute ¶
func (o *SequenceOperation) Execute(ctx context.Context, cli Client) error
func (*SequenceOperation) Format ¶
func (o *SequenceOperation) Format(resolver NameResolver) string
func (*SequenceOperation) String ¶
func (o *SequenceOperation) String() string
type ServiceSpecResolver ¶
type ServiceSpecResolver struct {
ClusterDomain string
}
ServiceSpecResolver transforms user-provided service specs into deployment-ready form.
func (*ServiceSpecResolver) Resolve ¶
func (r *ServiceSpecResolver) Resolve(spec api.ServiceSpec) (api.ServiceSpec, error)
Resolve transforms a service spec into its fully resolved form ready for deployment.
type StopContainerOperation ¶
StopContainerOperation stops a container on a specific machine.
func (*StopContainerOperation) Execute ¶
func (o *StopContainerOperation) Execute(ctx context.Context, cli Client) error
func (*StopContainerOperation) Format ¶
func (o *StopContainerOperation) Format(resolver NameResolver) string
func (*StopContainerOperation) String ¶
func (o *StopContainerOperation) String() string
type Strategy ¶
type Strategy interface {
// Type returns the type of the deployment strategy, e.g. "rolling", "blue-green".
Type() string
// Plan returns the operation to reconcile the service to the desired state.
// If the service does not exist (new deployment), svc will be nil. state provides the current and planned state
// of the cluster for scheduling decisions.
Plan(state *scheduler.ClusterState, svc *api.Service, spec api.ServiceSpec) (Plan, error)
}
Strategy defines how a service should be deployed or updated. Different implementations can provide various deployment patterns such as rolling updates, blue/green deployments, etc.