guvnor

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 34 Imported by: 0

README

guvnor

Handy tool for deploying containerised apps on Linux hosts.

Actions Status Coverage GitHub last commit GitHub issues GitHub pull requests License Status


WARNING: This product is currently unstable ! We do not recommend its use in production deployments.


Checkout https://guvnor.k.io/ for more information!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMultipleServices = errors.New("multiple services found, no default")
	ErrNoService        = errors.New("no service found")
)

Functions

This section is empty.

Types

type CleanupArgs added in v0.6.4

type CleanupArgs struct {
	ServiceName string
}

type ContainerStatus added in v0.5.2

type ContainerStatus struct {
	ContainerName string
	ContainerID   string
	Status        string
}

type DeployArgs added in v0.3.0

type DeployArgs struct {
	ServiceName string
	Tag         string
}

type DeployResult added in v0.7.2

type DeployResult struct {
	ServiceName  string
	DeploymentID int
}

type DeploymentStrategy added in v0.7.0

type DeploymentStrategy int
const (
	// DefaultStrategy
	//
	// Start new replica of process
	// Wait for that replica to become healthy
	// Direct traffic towards the new replica
	// Send SIGTERM to an old replica of process
	// Repeat until the count of new replicas meets the specified quantity
	// Clear up any remaining old replicas
	DefaultStrategy DeploymentStrategy = iota
	// ReplaceStrategy
	//
	// Remove an existing replica of the process from the loadbalancer
	// Send SIGTERM to the old replica
	// Wait for it stop, kiling it after X seconds if not stopped.
	// Start new replica of the process
	// Wait for it to become healthy
	// Direct traffic towards the new replica
	// Repeat until the count of new replicas meets the specified quantity
	// Clear up any remaining old replicas
	ReplaceStrategy
)

func (DeploymentStrategy) MarshalYAML added in v0.7.0

func (s DeploymentStrategy) MarshalYAML() (interface{}, error)

func (DeploymentStrategy) String added in v0.7.0

func (s DeploymentStrategy) String() string

func (*DeploymentStrategy) UnmarshalYAML added in v0.7.0

func (s *DeploymentStrategy) UnmarshalYAML(unmarshal func(interface{}) error) error

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(log *zap.Logger, docker client.APIClient, cfg EngineConfig, validate *validator.Validate) *Engine

func (*Engine) Cleanup added in v0.6.4

func (e *Engine) Cleanup(ctx context.Context, args CleanupArgs) error

func (*Engine) Deploy

func (e *Engine) Deploy(ctx context.Context, args DeployArgs) (*DeployResult, error)

func (*Engine) GetDefaultService added in v0.7.2

func (e *Engine) GetDefaultService() (*GetDefaultServiceResult, error)

func (*Engine) Purge

func (e *Engine) Purge(ctx context.Context) error

func (*Engine) RunTask added in v0.3.0

func (e *Engine) RunTask(ctx context.Context, args RunTaskArgs) error

func (*Engine) Status added in v0.4.0

func (e *Engine) Status(
	ctx context.Context, args StatusArgs,
) (*StatusResult, error)

type EngineConfig

type EngineConfig struct {
	Caddy caddy.Config `yaml:"caddy"`
	Paths PathsConfig  `yaml:"paths"`
}

func LoadConfig added in v0.3.0

func LoadConfig(validate *validator.Validate, pathOverride string) (*EngineConfig, error)

type GetDefaultServiceResult added in v0.7.2

type GetDefaultServiceResult struct {
	Name string
}

type NetworkConfig added in v0.4.5

type NetworkConfig struct {
	Mode *NetworkMode `yaml:"mode"`
}

type NetworkMode added in v0.4.1

type NetworkMode string
var (
	NetworkModeDefault NetworkMode = ""
	NetworkModeHost    NetworkMode = "host"
)

type PathsConfig

type PathsConfig struct {
	// Config is the path to the directory containing service configs
	Config string `yaml:"config" validate:"required"`
	// State is the path to store state about deployments etc
	State string `yaml:"state" validate:"required"`
}

type ProcessCaddyConfig

type ProcessCaddyConfig struct {
	Hostnames []string `yaml:"hostnames"`
	Path      string   `yaml:"path"`
}

type ProcessStatus added in v0.4.0

type ProcessStatus struct {
	WantReplicas int
	Containers   []ContainerStatus
}

type ProcessStatuses added in v0.5.2

type ProcessStatuses map[string]ProcessStatus

func (ProcessStatuses) OrderedKeys added in v0.5.2

func (ps ProcessStatuses) OrderedKeys() []string

type RunTaskArgs added in v0.3.0

type RunTaskArgs struct {
	ServiceName string
	TaskName    string
}

type ServiceCallbacksConfig added in v0.6.0

type ServiceCallbacksConfig struct {
	PreDeployment  []string `yaml:"preDeployment"`
	PostDeployment []string `yaml:"postDeployment"`
}

type ServiceConfig

type ServiceConfig struct {
	// Name is the unique identifier of the service, usually the name of the
	// file it has been retrieved from.
	Name string `yaml:"_"`
	// Defaults is a series of configuration values to use by default in
	// configuring process and task containers.
	Defaults ServiceDefaultsConfig `yaml:"defaults"`

	// Processes is a map of process name to configuration to deploy as part of
	// this service.
	Processes map[string]ServiceProcessConfig `yaml:"processes" validate:"dive"`
	// Tasks is a map of task names to configuration that are available for
	// invoking as part of this service.
	Tasks map[string]ServiceTaskConfig `yaml:"tasks" validate:"dive"`

	// Callbacks are definitions of Tasks to run when specific events occur,
	// e.g before a deployment.
	Callbacks ServiceCallbacksConfig `yaml:"callbacks"`
}

func (*ServiceConfig) Validate added in v0.6.0

func (sc *ServiceConfig) Validate(v *validator.Validate) error

type ServiceDefaultsConfig

type ServiceDefaultsConfig struct {
	Image     string               `yaml:"image"`
	ImageTag  string               `yaml:"imageTag"`
	ImagePull *bool                `yaml:"imagePull,omitempty"`
	Env       map[string]string    `yaml:"env"`
	Mounts    []ServiceMountConfig `yaml:"mounts"`
	Network   NetworkConfig        `yaml:"network"`

	// User allows the default User/Group to be specified for task and
	// process containers.
	//
	// The following formats are valid:
	// [ user | user:group | uid | uid:gid | user:gid | uid:group ]
	User string `yaml:"user"`
}

type ServiceMountConfig

type ServiceMountConfig struct {
	Host      string `yaml:"host"`
	Container string `yaml:"container"`
}

type ServiceProcessConfig

type ServiceProcessConfig struct {
	Image     string               `yaml:"image"`
	ImageTag  string               `yaml:"imageTag"`
	ImagePull *bool                `yaml:"imagePull,omitempty"`
	Command   []string             `yaml:"command"`
	Quantity  int                  `yaml:"quantity"`
	Env       map[string]string    `yaml:"env"`
	Mounts    []ServiceMountConfig `yaml:"mounts"`
	Caddy     ProcessCaddyConfig   `yaml:"caddy"`

	// Privileged grants all capabilities to the container.
	Privileged bool `yaml:"privileged"`

	// User allows the User/Group to be configured for the process container.
	//
	// The following formats are valid:
	// [ user | user:group | uid | uid:gid | user:gid | uid:group ]
	User string `yaml:"user"`

	Network    NetworkConfig `yaml:"network"`
	ReadyCheck *ready.Check  `yaml:"readyCheck"`

	// TODO: add validation to constrain this value
	DeploymentStrategy  DeploymentStrategy `yaml:"deploymentStrategy"`
	ShutdownGracePeriod time.Duration      `yaml:"shutdownGracePeriod"`
	// contains filtered or unexported fields
}

func (ServiceProcessConfig) GetImage added in v0.6.3

func (spc ServiceProcessConfig) GetImage() (string, bool, error)

func (ServiceProcessConfig) GetMounts added in v0.6.3

func (spc ServiceProcessConfig) GetMounts() []mount.Mount

func (ServiceProcessConfig) GetNetworkMode added in v0.6.4

func (spc ServiceProcessConfig) GetNetworkMode() NetworkMode

func (ServiceProcessConfig) GetQuantity added in v0.4.5

func (spc ServiceProcessConfig) GetQuantity() int

func (ServiceProcessConfig) GetShutdownGracePeriod added in v0.7.2

func (spc ServiceProcessConfig) GetShutdownGracePeriod() time.Duration

func (ServiceProcessConfig) GetUser added in v0.6.3

func (spc ServiceProcessConfig) GetUser() string

type ServiceTaskConfig added in v0.3.0

type ServiceTaskConfig struct {
	Image       string               `yaml:"image"`
	ImageTag    string               `yaml:"imageTag"`
	ImagePull   *bool                `yaml:"imagePull,omitempty"`
	Command     []string             `yaml:"command"`
	Interactive bool                 `yaml:"interactive"`
	Env         map[string]string    `yaml:"env"`
	Mounts      []ServiceMountConfig `yaml:"mounts"`
	Network     NetworkConfig        `yaml:"network"`

	// User allows the User/Group to be configured for the task container.
	//
	// The following formats are valid:
	// [ user | user:group | uid | uid:gid | user:gid | uid:group ]
	User string `yaml:"user"`
	// contains filtered or unexported fields
}

func (ServiceTaskConfig) GetImage added in v0.6.3

func (stc ServiceTaskConfig) GetImage() (string, bool, error)

func (ServiceTaskConfig) GetMounts added in v0.6.3

func (stc ServiceTaskConfig) GetMounts() []mount.Mount

func (ServiceTaskConfig) GetNetworkMode added in v0.6.4

func (stc ServiceTaskConfig) GetNetworkMode() NetworkMode

func (ServiceTaskConfig) GetUser added in v0.6.3

func (stc ServiceTaskConfig) GetUser() string

type StatusArgs added in v0.4.0

type StatusArgs struct {
	ServiceName string
}

type StatusResult added in v0.7.2

type StatusResult struct {
	DeploymentID   int
	LastDeployedAt time.Time
	Processes      ProcessStatuses
}

Directories

Path Synopsis
cmd
guvnor
Package main is a generated GoMock package.
Package main is a generated GoMock package.

Jump to

Keyboard shortcuts

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