Documentation ¶
Overview ¶
Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.
Index ¶
- Constants
- Variables
- func AppProcessName(a App, process string, version int, suffix string) string
- func DefaultWebPortEnvs() []bindTypes.EnvVar
- func EnvsForApp(a App, process string, isDeploy bool, version appTypes.AppVersion) []bindTypes.EnvVar
- func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
- func InitializeAll() error
- func MainAppProcess(processes []string) string
- func Register(name string, pFunc provisionerFactory)
- func Unregister(name string)
- func ValidKubeName(name string) string
- func WebProcessDefaultPort() string
- type App
- type AppFilterProvisioner
- type AppInternalAddress
- type AutoScaleProvisioner
- type AutoScaleSchedule
- type AutoScaleSpec
- type BuilderDeploy
- type DeployArgs
- type ErrUnitStartup
- type Error
- type ExecOptions
- type ExecutableProvisioner
- type HCProvisioner
- type ImageBuildLabelsOpts
- type InitializableProvisioner
- type InspectData
- type InterAppProvisioner
- type InvalidProcessError
- type JobProvisioner
- type KillUnitProvisioner
- type LabelSet
- func ImageBuildLabels(opts ImageBuildLabelsOpts) *LabelSet
- func JobLabels(ctx context.Context, job *jobTypes.Job) *LabelSet
- func NodeLabels(opts NodeLabelsOpts) *LabelSet
- func PDBLabels(opts PDBLabelsOpts) *LabelSet
- func ProcessLabels(ctx context.Context, opts ProcessLabelsOpts) (*LabelSet, error)
- func ServiceAccountLabels(opts ServiceAccountLabelsOpts) *LabelSet
- func ServiceLabelSet(prefix string) *LabelSet
- func ServiceLabels(ctx context.Context, opts ServiceLabelsOpts) (*LabelSet, error)
- func TsuruJobLabelSet(prefix string) *LabelSet
- func VolumeLabels(opts VolumeLabelsOpts) *LabelSet
- func (s *LabelSet) AppName() string
- func (s *LabelSet) AppPlatform() string
- func (s *LabelSet) AppPool() string
- func (s *LabelSet) AppProcess() string
- func (s *LabelSet) AppVersion() int
- func (s *LabelSet) BuildImage() string
- func (s *LabelSet) DeepCopy() *LabelSet
- func (s *LabelSet) IsBase() bool
- func (s *LabelSet) IsDeploy() bool
- func (s *LabelSet) IsHeadlessService() bool
- func (s *LabelSet) IsIsolatedRun() bool
- func (s *LabelSet) IsRoutable() bool
- func (s *LabelSet) IsService() bool
- func (s *LabelSet) IsStopped() bool
- func (s *LabelSet) JobName() string
- func (s *LabelSet) Merge(override *LabelSet) *LabelSet
- func (s *LabelSet) NodeAddr() string
- func (s *LabelSet) NodeExtraData(cluster string) map[string]string
- func (s *LabelSet) NodeMetadata() map[string]string
- func (s *LabelSet) NodeMetadataNoPrefix() map[string]string
- func (s *LabelSet) NodePool() string
- func (s *LabelSet) ReplaceIsIsolatedNewRunWithBase()
- func (s *LabelSet) ReplaceIsIsolatedRunWithNew()
- func (s *LabelSet) Restarts() int
- func (s *LabelSet) SetBuildImage(image string)
- func (s *LabelSet) SetIsHeadlessService()
- func (s *LabelSet) SetIsRoutable()
- func (s *LabelSet) SetIsService()
- func (s *LabelSet) SetRestarts(count int)
- func (s *LabelSet) SetStopped()
- func (s *LabelSet) SetVersion(version int)
- func (s *LabelSet) ToAllVersionsSelector() map[string]string
- func (s *LabelSet) ToAppSelector() map[string]string
- func (s *LabelSet) ToBaseSelector() map[string]string
- func (s *LabelSet) ToHPASelector() map[string]string
- func (s *LabelSet) ToIsServiceSelector() map[string]string
- func (s *LabelSet) ToJobSelector() map[string]string
- func (s *LabelSet) ToLabels() map[string]string
- func (s *LabelSet) ToNodeByPoolSelector() map[string]string
- func (s *LabelSet) ToNodeContainerSelector() map[string]string
- func (s *LabelSet) ToNodeSelector() map[string]string
- func (s *LabelSet) ToPDBSelector() map[string]string
- func (s *LabelSet) ToRoutableSelector() map[string]string
- func (s *LabelSet) ToVersionSelector() map[string]string
- func (s *LabelSet) ToVolumeSelector() map[string]string
- func (s *LabelSet) ToggleIsRoutable(isRoutable bool)
- func (s *LabelSet) WithoutIsolated() *LabelSet
- func (s *LabelSet) WithoutRoutable() *LabelSet
- func (s *LabelSet) WithoutVersion() *LabelSet
- type LogsProvisioner
- type MessageProvisioner
- type MetricsProvisioner
- type MultiRegistryProvisioner
- type Named
- type NodeCheckResult
- type NodeLabelsOpts
- type OptionalLogsProvisioner
- type PDBLabelsOpts
- type ProcessLabelsOpts
- type Provisioner
- type ProvisionerNotSupported
- type RebalanceNodesOptions
- type RecommendedProcessResources
- type RecommendedResources
- type RunArgs
- type ServiceAccountLabelsOpts
- type ServiceLabelExtendedOpts
- type ServiceLabelsOpts
- type Status
- type Unit
- type UnitFinderProvisioner
- type UnitMetric
- type UnitNotFoundError
- type UnitStatusData
- type UnitStatusProvisioner
- type UpdatableProvisioner
- type VersionsProvisioner
- type VolumeLabelsOpts
- type VolumeProvisioner
Constants ¶
const ( LabelIsBuild = "is-build" LabelIsDeploy = "is-deploy" LabelAppName = "app-name" LabelAppProcess = "app-process" LabelAppPool = "app-pool" LabelAppPlatform = "app-platform" LabelAppVersion = "app-version" LabelAppTeamOwner = "app-team" LabelIsJob = "is-job" LabelJobName = "job-name" LabelJobPool = "job-pool" LabelJobTeamOwner = "job-team" LabelJobIsManual = "job-manual" LabelNodePool = PoolMetadataName )
const ( DefaultHealthcheckScheme = "http" PoolMetadataName = "pool" WebProcessName = "web" )
const ( // StatusCreated is the initial status of a unit in the database, // it should transition shortly to a more specific status StatusCreated = Status("created") // StatusBuilding is the status for units being provisioned by the // provisioner, like in the deployment. StatusBuilding = Status("building") // StatusError is the status for units that failed to start, because of // an application error. StatusError = Status("error") // StatusStarting is set when the container is started in docker. StatusStarting = Status("starting") // StatusStarted is for cases where the unit is up and running, and bound // to the proper status, it's set by RegisterUnit and SetUnitStatus. StatusStarted = Status("started") // StatusStopped is for cases where the unit has been stopped. StatusStopped = Status("stopped") // StatusSucceeded is for alternete cases where the unit has been // stopped with succeeded end. StatusSucceeded = Status("succeeded") )
+---------+ +----------+ +---------+ | Created | +---------> | Starting | +-------------> | Started | +---------+ +----------+ +---------+
^ + + | | | | | | | | | v | | +-------+ | | | Error | +---------------+ | +-------+ ------------------+
Variables ¶
Functions ¶
func DefaultWebPortEnvs ¶
func EnvsForApp ¶
func ExtendServiceLabels ¶
func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
func InitializeAll ¶
func InitializeAll() error
func MainAppProcess ¶
func Register ¶
func Register(name string, pFunc provisionerFactory)
Register registers a new provisioner in the Provisioner registry.
func ValidKubeName ¶
func WebProcessDefaultPort ¶
func WebProcessDefaultPort() string
Types ¶
type App ¶
type App interface { Named // GetPlatform returns the platform (type) of the app. It is equivalent // to the Unit `Type` field. GetPlatform() string // GetPlatformVersion returns the locked platform version of the app. GetPlatformVersion() string // GetDeploy returns the deploys that an app has. GetDeploys() uint Envs() map[string]bindTypes.EnvVar GetUpdatePlatform() bool GetRouters() []appTypes.AppRouter GetTeamOwner() string GetTeamsName() []string GetPlan() appTypes.Plan GetPool() string GetProcess(process string) *appTypes.Process ListTags() []string GetMetadata(process string) appTypes.Metadata GetRegistry() (imgTypes.ImageRegistry, error) }
App represents a tsuru app.
It contains only relevant information for provisioning.
type AppFilterProvisioner ¶
type AppFilterProvisioner interface {
FilterAppsByUnitStatus(context.Context, []App, []string) ([]App, error)
}
AppFilterProvisioner is a provisioner that allows filtering apps by the state of its units.
type AppInternalAddress ¶
type AutoScaleProvisioner ¶
type AutoScaleProvisioner interface { GetAutoScale(ctx context.Context, a App) ([]AutoScaleSpec, error) GetVerticalAutoScaleRecommendations(ctx context.Context, a App) ([]RecommendedResources, error) SetAutoScale(ctx context.Context, a App, spec AutoScaleSpec) error RemoveAutoScale(ctx context.Context, a App, process string) error }
type AutoScaleSchedule ¶
type AutoScaleSpec ¶
type AutoScaleSpec struct { Process string `json:"process"` MinUnits uint `json:"minUnits"` MaxUnits uint `json:"maxUnits"` AverageCPU string `json:"averageCPU,omitempty"` Schedules []AutoScaleSchedule `json:"schedules,omitempty"` Version int `json:"version"` }
func (AutoScaleSpec) ToCPUValue ¶
func (s AutoScaleSpec) ToCPUValue(a App) (int, error)
type BuilderDeploy ¶
type BuilderDeploy interface {
Deploy(context.Context, DeployArgs) (string, error)
}
BuilderDeploy is a provisioner that allows deploy builded image.
type DeployArgs ¶
type ErrUnitStartup ¶
func IsStartupError ¶
func IsStartupError(err error) (*ErrUnitStartup, bool)
func (ErrUnitStartup) Cause ¶
func (e ErrUnitStartup) Cause() error
func (ErrUnitStartup) Error ¶
func (e ErrUnitStartup) Error() string
type ExecOptions ¶
type ExecutableProvisioner ¶
type ExecutableProvisioner interface {
ExecuteCommand(ctx context.Context, opts ExecOptions) error
}
type HCProvisioner ¶
type HCProvisioner interface { // HandlesHC returns true if the provisioner will handle healthchecking // instead of the router. HandlesHC() bool }
HCProvisioner is a provisioner that may handle loadbalancing healthchecks.
type ImageBuildLabelsOpts ¶
type InitializableProvisioner ¶
type InitializableProvisioner interface {
Initialize() error
}
InitializableProvisioner is a provisioner that provides an initialization method that should be called when the app is started
type InspectData ¶
type InspectData struct { Image docker.Image TsuruYaml provTypes.TsuruYamlData Procfile string }
type InterAppProvisioner ¶
type InterAppProvisioner interface {
InternalAddresses(ctx context.Context, a App) ([]AppInternalAddress, error)
}
InterAppProvisioner is a provisioner that allows an app to comunicate with each other using internal dns and own load balancers provided by provisioner.
type InvalidProcessError ¶
type InvalidProcessError struct {
Msg string
}
func (InvalidProcessError) Error ¶
func (e InvalidProcessError) Error() string
type JobProvisioner ¶
type JobProvisioner interface { // JobUnits returns information about units related to a specific Job or CronJob JobUnits(context.Context, *jobTypes.Job) ([]Unit, error) // EnsureJob creates/update a cronjob object in the cluster EnsureJob(context.Context, *jobTypes.Job) error DestroyJob(context.Context, *jobTypes.Job) error TriggerCron(ctx context.Context, name, pool string) error KillJobUnit(ctx context.Context, job *jobTypes.Job, unitName string, force bool) error }
type KillUnitProvisioner ¶
type LabelSet ¶
func ImageBuildLabels ¶
func ImageBuildLabels(opts ImageBuildLabelsOpts) *LabelSet
func NodeLabels ¶
func NodeLabels(opts NodeLabelsOpts) *LabelSet
func PDBLabels ¶
func PDBLabels(opts PDBLabelsOpts) *LabelSet
func ProcessLabels ¶
func ProcessLabels(ctx context.Context, opts ProcessLabelsOpts) (*LabelSet, error)
func ServiceAccountLabels ¶
func ServiceAccountLabels(opts ServiceAccountLabelsOpts) *LabelSet
func ServiceLabelSet ¶
func ServiceLabels ¶
func ServiceLabels(ctx context.Context, opts ServiceLabelsOpts) (*LabelSet, error)
func TsuruJobLabelSet ¶
func VolumeLabels ¶
func VolumeLabels(opts VolumeLabelsOpts) *LabelSet
func (*LabelSet) AppPlatform ¶
func (*LabelSet) AppProcess ¶
func (*LabelSet) AppVersion ¶
func (*LabelSet) BuildImage ¶
func (*LabelSet) IsHeadlessService ¶
func (*LabelSet) IsIsolatedRun ¶
func (*LabelSet) IsRoutable ¶
func (*LabelSet) NodeMetadata ¶
func (*LabelSet) NodeMetadataNoPrefix ¶
func (*LabelSet) ReplaceIsIsolatedNewRunWithBase ¶
func (s *LabelSet) ReplaceIsIsolatedNewRunWithBase()
func (*LabelSet) ReplaceIsIsolatedRunWithNew ¶
func (s *LabelSet) ReplaceIsIsolatedRunWithNew()
func (*LabelSet) SetBuildImage ¶
func (*LabelSet) SetIsHeadlessService ¶
func (s *LabelSet) SetIsHeadlessService()
func (*LabelSet) SetIsRoutable ¶
func (s *LabelSet) SetIsRoutable()
func (*LabelSet) SetIsService ¶
func (s *LabelSet) SetIsService()
func (*LabelSet) SetRestarts ¶
func (*LabelSet) SetStopped ¶
func (s *LabelSet) SetStopped()
func (*LabelSet) SetVersion ¶
func (*LabelSet) ToAllVersionsSelector ¶
func (*LabelSet) ToAppSelector ¶
func (*LabelSet) ToBaseSelector ¶
func (*LabelSet) ToHPASelector ¶
func (*LabelSet) ToIsServiceSelector ¶
func (*LabelSet) ToJobSelector ¶
func (*LabelSet) ToNodeByPoolSelector ¶
func (*LabelSet) ToNodeContainerSelector ¶
func (*LabelSet) ToNodeSelector ¶
func (*LabelSet) ToPDBSelector ¶
func (*LabelSet) ToRoutableSelector ¶
func (*LabelSet) ToVersionSelector ¶
func (*LabelSet) ToVolumeSelector ¶
func (*LabelSet) ToggleIsRoutable ¶
func (*LabelSet) WithoutIsolated ¶
func (*LabelSet) WithoutRoutable ¶
func (*LabelSet) WithoutVersion ¶
type LogsProvisioner ¶
type LogsProvisioner interface { ListLogs(ctx context.Context, obj logTypes.LogabbleObject, args appTypes.ListLogArgs) ([]appTypes.Applog, error) WatchLogs(ctx context.Context, obj logTypes.LogabbleObject, args appTypes.ListLogArgs) (appTypes.LogWatcher, error) }
LogsProvisioner is a provisioner that is self responsible for storage logs.
type MessageProvisioner ¶
MessageProvisioner is a provisioner that provides a welcome message for logging.
type MetricsProvisioner ¶
type MetricsProvisioner interface { // Units returns information about cpu and memory usage by App. UnitsMetrics(ctx context.Context, a App) ([]UnitMetric, error) }
MetricsProvisioner is a provisioner that have capability to view metrics of workloads
type Named ¶
type Named interface {
GetName() string
}
Named is something that has a name, providing the GetName method.
type NodeCheckResult ¶
type NodeLabelsOpts ¶
type OptionalLogsProvisioner ¶
type OptionalLogsProvisioner interface { // Checks if logs are enabled for given app. LogsEnabled(App) (bool, string, error) }
OptionalLogsProvisioner is a provisioner that allows optionally disabling logs for a given app.
type PDBLabelsOpts ¶
type ProcessLabelsOpts ¶
type Provisioner ¶
type Provisioner interface { Named // Provision is called when tsuru is creating the app. Provision(context.Context, App) error // Destroy is called when tsuru is destroying the app. Destroy(context.Context, App) error // DestroyVersion is called when tsuru is destroying an app version. DestroyVersion(context.Context, App, appTypes.AppVersion) error // AddUnits adds units to an app. The first parameter is the app, the // second is the number of units to be added. // // It returns a slice containing all added units AddUnits(context.Context, App, uint, string, appTypes.AppVersion, io.Writer) error // RemoveUnits "undoes" AddUnits, removing the given number of units // from the app. RemoveUnits(context.Context, App, uint, string, appTypes.AppVersion, io.Writer) error // Restart restarts the units of the application, with an optional // string parameter represeting the name of the process to start. When // the process is empty, Restart will restart all units of the // application. Restart(context.Context, App, string, appTypes.AppVersion, io.Writer) error // Start starts the units of the application, with an optional string // parameter representing the name of the process to start. When the // process is empty, Start will start all units of the application. Start(context.Context, App, string, appTypes.AppVersion, io.Writer) error // Stop stops the units of the application, with an optional string // parameter representing the name of the process to start. When the // process is empty, Stop will stop all units of the application. Stop(context.Context, App, string, appTypes.AppVersion, io.Writer) error // Units returns information about units by App. Units(context.Context, ...App) ([]Unit, error) // RoutableAddresses returns the addresses used to access an application. RoutableAddresses(context.Context, App) ([]appTypes.RoutableAddresses, error) // Register a unit after the container has been created or restarted. RegisterUnit(context.Context, App, string, map[string]interface{}) error }
Provisioner is the basic interface of this package.
Any tsuru provisioner must implement this interface in order to provision tsuru apps.
func Get ¶
func Get(name string) (Provisioner, error)
Get gets the named provisioner from the registry.
func GetDefault ¶
func GetDefault() (Provisioner, error)
func Registry ¶
func Registry() ([]Provisioner, error)
Registry returns the list of registered provisioners.
type ProvisionerNotSupported ¶
type ProvisionerNotSupported struct { Prov Provisioner Action string }
func (ProvisionerNotSupported) Error ¶
func (e ProvisionerNotSupported) Error() string
type RebalanceNodesOptions ¶
type RecommendedResources ¶
type RecommendedResources struct { Process string `json:"process"` Recommendations []RecommendedProcessResources `json:"recommendations"` }
type ServiceLabelsOpts ¶
type ServiceLabelsOpts struct { App App Process string Version int ServiceLabelExtendedOpts }
type Status ¶
type Status string
Status represents the status of a unit in tsuru.
func ParseStatus ¶
type Unit ¶
type Unit struct { ID string Name string AppName string ProcessName string Type string IP string InternalIP string Status Status StatusReason string Address *url.URL // TODO: deprecate after drop docker provisioner Addresses []url.URL // TODO: deprecate after drop docker provisioner Version int Routable bool Restarts *int32 CreatedAt *time.Time Ready *bool }
Unit represents a provision unit. Can be a machine, container or anything IP-addressable.
func (*Unit) Available ¶
Available returns true if the unit is available. It will return true whenever the unit itself is available, even when the application process is not.
func (*Unit) MarshalJSON ¶
type UnitFinderProvisioner ¶
type UnitFinderProvisioner interface { // GetAppFromUnitID returns an app from unit id GetAppFromUnitID(context.Context, string) (App, error) }
UnitFinderProvisioner is a provisioner that allows finding a specific unit by its id. New provisioners should not implement this interface, this was only used during events format migration and is exclusive to docker provisioner.
type UnitMetric ¶
UnitMetric represents a a related metrics for an unit.
type UnitNotFoundError ¶
type UnitNotFoundError struct {
ID string
}
func (*UnitNotFoundError) Error ¶
func (e *UnitNotFoundError) Error() string
type UnitStatusData ¶
type UnitStatusProvisioner ¶
type UnitStatusProvisioner interface { // SetUnitStatus changes the status of a unit. SetUnitStatus(Unit, Status) error }
UnitStatusProvisioner is a provisioner that receive notifications about unit status changes.
type UpdatableProvisioner ¶
type UpdatableProvisioner interface {
UpdateApp(ctx context.Context, old, new App, w io.Writer) error
}
UpdatableProvisioner is a provisioner that stores data about applications and must be notified when they are updated
type VersionsProvisioner ¶
type VolumeLabelsOpts ¶
Directories ¶
Path | Synopsis |
---|---|
pkg/apis/tsuru/v1
Package v1 is the v1 version of the API.
|
Package v1 is the v1 version of the API. |
pkg/client/clientset/versioned
This package has the automatically generated clientset.
|
This package has the automatically generated clientset. |
pkg/client/clientset/versioned/fake
This package has the automatically generated fake clientset.
|
This package has the automatically generated fake clientset. |
pkg/client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
|
This package contains the scheme of the automatically generated clientset. |
pkg/client/clientset/versioned/typed/tsuru/v1
This package has the automatically generated typed clients.
|
This package has the automatically generated typed clients. |
pkg/client/clientset/versioned/typed/tsuru/v1/fake
Package fake has the automatically generated clients.
|
Package fake has the automatically generated clients. |