deploy

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerUpdateOptions added in v0.22.0

func ContainerUpdateOptions(current api.ServiceContainer, new api.ServiceSpec) api.UpdateContainerOptions

ContainerUpdateOptions returns the container properties that can be updated in place and differ between the new spec and either the container spec or the limits Docker applies to the container. It should only be used when EvalContainerChange returns ContainerNeedsUpdate.

func GenerateServiceName added in v0.6.0

func GenerateServiceName(image string) (string, error)

Types

type ContainerSpecStatus

type ContainerSpecStatus string
const (
	ContainerUpToDate ContainerSpecStatus = "up-to-date"
	// ContainerNeedsUpdate means the container can be updated in place without recreating it.
	ContainerNeedsUpdate   ContainerSpecStatus = "needs-update"
	ContainerNeedsRecreate ContainerSpecStatus = "needs-recreate"
)

func EvalContainerChange added in v0.22.0

func EvalContainerChange(current api.ServiceContainer, new api.ServiceSpec) ContainerSpecStatus

EvalContainerChange evaluates whether the running container matches the new spec, can be updated in place to match it, or needs to be recreated. Unlike EvalContainerSpecChange, it also compares the new spec with the CPU and memory limits that Docker applies to the container, so the container is updated when they drifted from its spec.

func EvalContainerSpecChange

func EvalContainerSpecChange(current api.ServiceSpec, new api.ServiceSpec) ContainerSpecStatus

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) (ServicePlan, 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) (ServicePlan, 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.

func (*Deployment) Validate

func (d *Deployment) Validate(ctx context.Context) error

Validate checks if the deployment specification is valid.

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
	// SkipHealthMonitor skips the monitoring period and health checks for faster emergency deployments.
	SkipHealthMonitor 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 (*RollingStrategy) Type

func (s *RollingStrategy) Type() string

type ServicePlan added in v0.18.0

type ServicePlan struct {
	ServiceID   string
	ServiceName string
	// IsNewService indicates this plan creates a new service (first deployment) rather than updating an existing one.
	IsNewService bool
	// Spec is the desired service spec being deployed.
	Spec api.ServiceSpec
	operation.SequenceOperation
}

func (*ServicePlan) Format added in v0.18.0

func (sp *ServicePlan) Format() string

Format renders the service plan as a styled block with a spec diff and nested container operations.

func (*ServicePlan) FormatSummary added in v0.18.0

func (sp *ServicePlan) FormatSummary() string

FormatSummary counts operations in the service plan and renders a styled summary line.

type ServiceSpecResolver

type ServiceSpecResolver struct {
	ClusterDomain string
}

ServiceSpecResolver transforms user-provided service specs into deployment-ready form.

func (*ServiceSpecResolver) Resolve

Resolve transforms a service spec into its fully resolved form ready for deployment.

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) (ServicePlan, 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL