Documentation
¶
Overview ¶
Package caasapplicationprovisioner defines two types of worker:
- provisioner: Watches a Kubernetes model and starts a new worker of the appWorker type whenever an application is created.
- appWorker: Drives the Kubernetes provider to create, manage, and destroy Kubernetes resources to match a requested state. Also writes the state of created resources (application/unit status, application/unit IP addresses & ports, filesystem info, etc.) back into the database.
Index ¶
- func Manifold(config ManifoldConfig) dependency.Manifold
- func NewAppWorker(config AppWorkerConfig) func() (worker.Worker, error)
- func NewProvisionerWorker(config Config) (worker.Worker, error)
- type AppWorkerConfig
- type ApplicationOps
- type CAASBroker
- type CAASProvisionerFacade
- type CAASUnitProvisionerFacade
- type Config
- type ManifoldConfig
- type NewAppWorkerFunc
- type Runner
- type Tomb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold creates a manifold that runs a CAAS operator provisioner. See the ManifoldConfig type for discussion about how this can/should evolve.
func NewAppWorker ¶
func NewAppWorker(config AppWorkerConfig) func() (worker.Worker, error)
Types ¶
type AppWorkerConfig ¶
type AppWorkerConfig struct {
Name string
Facade CAASProvisionerFacade
Broker CAASBroker
ModelTag names.ModelTag
Clock clock.Clock
Logger logger.Logger
UnitFacade CAASUnitProvisionerFacade
Ops ApplicationOps
StatusOnly bool
}
type ApplicationOps ¶
type ApplicationOps interface {
AppAlive(ctx context.Context, appName string, app caas.Application,
password string, lastApplied *caas.ApplicationConfig,
facade CAASProvisionerFacade, clk clock.Clock, logger logger.Logger) error
AppDying(ctx context.Context, appName string, app caas.Application, appLife life.Value,
facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error
AppDead(ctx context.Context, appName string, app caas.Application,
broker CAASBroker, facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade,
clk clock.Clock, logger logger.Logger) error
CheckCharmFormat(ctx context.Context, appName string,
facade CAASProvisionerFacade, logger logger.Logger) (isOk bool, err error)
EnsureTrust(ctx context.Context, appName string, app caas.Application,
unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error
UpdateState(ctx context.Context, appName string, app caas.Application, lastReportedStatus map[string]status.StatusInfo,
broker CAASBroker, facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) (map[string]status.StatusInfo, error)
RefreshApplicationStatus(ctx context.Context, appName string, app caas.Application, appLife life.Value,
facade CAASProvisionerFacade, logger logger.Logger) error
WaitForTerminated(appName string, app caas.Application,
clk clock.Clock) error
ReconcileDeadUnitScale(ctx context.Context, appName string, app caas.Application,
facade CAASProvisionerFacade, logger logger.Logger) error
EnsureScale(ctx context.Context, appName string, app caas.Application, appLife life.Value,
facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error
}
ApplicationOps defines all the operations the application worker can perform. This is exported for testing only.
type CAASBroker ¶
type CAASBroker interface {
Application(string, caas.DeploymentType) caas.Application
AnnotateUnit(ctx context.Context, appName string, podName string, unit names.UnitTag) error
Units(ctx context.Context, appName string) ([]caas.Unit, error)
}
CAASBroker exposes CAAS broker functionality to a worker.
type CAASProvisionerFacade ¶
type CAASProvisionerFacade interface {
ProvisioningInfo(context.Context, string) (api.ProvisioningInfo, error)
WatchApplications(context.Context) (watcher.StringsWatcher, error)
SetPassword(context.Context, string, string) error
Life(context.Context, string) (life.Value, error)
CharmInfo(context.Context, string) (*charmscommon.CharmInfo, error)
ApplicationCharmInfo(context.Context, string) (*charmscommon.CharmInfo, error)
SetOperatorStatus(ctx context.Context, appName string, status status.Status, message string, data map[string]interface{}) error
Units(ctx context.Context, appName string) ([]params.CAASUnit, error)
ApplicationOCIResources(ctx context.Context, appName string) (map[string]resource.DockerImageDetails, error)
UpdateUnits(ctx context.Context, arg params.UpdateApplicationUnits) (*params.UpdateApplicationUnitsInfo, error)
WatchApplication(ctx context.Context, appName string) (watcher.NotifyWatcher, error)
ClearApplicationResources(ctx context.Context, appName string) error
WatchUnits(ctx context.Context, application string) (watcher.StringsWatcher, error)
RemoveUnit(ctx context.Context, unitName string) error
WatchProvisioningInfo(context.Context, string) (watcher.NotifyWatcher, error)
DestroyUnits(ctx context.Context, unitNames []string) error
ProvisioningState(context.Context, string) (*params.CAASApplicationProvisioningState, error)
SetProvisioningState(context.Context, string, params.CAASApplicationProvisioningState) error
ProvisionerConfig(context.Context) (params.CAASApplicationProvisionerConfig, error)
}
CAASProvisionerFacade exposes CAAS provisioning functionality to a worker.
type CAASUnitProvisionerFacade ¶
type CAASUnitProvisionerFacade interface {
ApplicationScale(context.Context, string) (int, error)
WatchApplicationScale(context.Context, string) (watcher.NotifyWatcher, error)
ApplicationTrust(context.Context, string) (bool, error)
WatchApplicationTrustHash(context.Context, string) (watcher.StringsWatcher, error)
UpdateApplicationService(ctx context.Context, arg params.UpdateApplicationServiceArg) error
}
type Config ¶
type Config struct {
Facade CAASProvisionerFacade
Broker CAASBroker
ModelTag names.ModelTag
Clock clock.Clock
Logger logger.Logger
NewAppWorker NewAppWorkerFunc
UnitFacade CAASUnitProvisionerFacade
}
Config defines the operation of a Worker.
type ManifoldConfig ¶
type ManifoldConfig struct {
APICallerName string
BrokerName string
ClockName string
NewWorker func(Config) (worker.Worker, error)
Logger logger.Logger
}
ManifoldConfig defines a CAAS operator provisioner's dependencies.
func (ManifoldConfig) Validate ¶
func (config ManifoldConfig) Validate() error
Validate is called by start to check for bad configuration.
type NewAppWorkerFunc ¶
type NewAppWorkerFunc func(AppWorkerConfig) func() (worker.Worker, error)
Click to show internal directories.
Click to hide internal directories.