Documentation ¶
Overview ¶
Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.
Index ¶
- Constants
- Variables
- func DefaultWebPortEnvs() []bind.EnvVar
- func EnvsForApp(a App, process string, isDeploy bool) []bind.EnvVar
- func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
- func InitializeAll() error
- func IsStartupError(err error) bool
- func NodeToJSON(n Node) ([]byte, error)
- func Register(name string, pFunc provisionerFactory)
- func SplitServiceLabelsAnnotations(ls *LabelSet) (labels *LabelSet, ann *LabelSet)
- func Unregister(name string)
- func WebProcessDefaultPort() string
- type ActionLimiter
- type AddNodeOptions
- type App
- type AppFilterProvisioner
- type AppLock
- type BuilderDeploy
- type BuilderDeployDockerClient
- type BuilderDeployKubeClient
- type BuilderDockerClient
- type BuilderKubeClient
- type CleanImageProvisioner
- type ErrUnitStartup
- type Error
- type ExecDockerClient
- type ExecOptions
- type ExecutableProvisioner
- type ImageBuildLabelsOpts
- type InitializableProvisioner
- type InvalidProcessError
- type LabelSet
- func ImageBuildLabels(opts ImageBuildLabelsOpts) *LabelSet
- func NodeContainerLabels(opts NodeContainerLabelsOpts) *LabelSet
- func NodeLabels(opts NodeLabelsOpts) *LabelSet
- func ProcessLabels(opts ProcessLabelsOpts) (*LabelSet, error)
- func ServiceAccountLabels(opts ServiceAccountLabelsOpts) *LabelSet
- func ServiceLabels(opts ServiceLabelsOpts) (*LabelSet, error)
- 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) AppReplicas() int
- func (s *LabelSet) BuildImage() string
- func (s *LabelSet) IsAsleep() bool
- func (s *LabelSet) IsDeploy() bool
- func (s *LabelSet) IsIsolatedRun() bool
- func (s *LabelSet) IsService() bool
- func (s *LabelSet) IsStopped() bool
- func (s *LabelSet) NodeAddr() string
- func (s *LabelSet) NodeExtraData(cluster string) map[string]string
- func (s *LabelSet) NodeIaaSID() string
- func (s *LabelSet) NodeMetadata() map[string]string
- func (s *LabelSet) NodeMetadataNoPrefix() map[string]string
- func (s *LabelSet) NodePool() string
- func (s *LabelSet) Restarts() int
- func (s *LabelSet) SetAsleep()
- func (s *LabelSet) SetBuildImage(image string)
- func (s *LabelSet) SetIsHeadlessService()
- func (s *LabelSet) SetIsService()
- func (s *LabelSet) SetRestarts(count int)
- func (s *LabelSet) SetStopped()
- func (s *LabelSet) ToAppSelector() map[string]string
- func (s *LabelSet) ToIsServiceSelector() 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) ToSelector() map[string]string
- func (s *LabelSet) ToVolumeSelector() map[string]string
- func (s *LabelSet) WithoutAppReplicas() *LabelSet
- type LocalLimiter
- type MessageProvisioner
- type MongodbLimiter
- type Named
- type Node
- type NodeCheckResult
- type NodeContainerLabelsOpts
- type NodeContainerProvisioner
- type NodeExtraData
- type NodeHealthChecker
- type NodeLabelsOpts
- type NodeProvisioner
- type NodeRebalanceProvisioner
- type NodeSpec
- type NodeStatusData
- type OptionalLogsProvisioner
- type ProcessLabelsOpts
- type Provisioner
- type ProvisionerNotSupported
- type RebalanceNodesOptions
- type RemoveNodeOptions
- type RollbackableDeployer
- type RunArgs
- type ServiceAccountLabelsOpts
- type ServiceLabelExtendedOpts
- type ServiceLabelsOpts
- type SleepableProvisioner
- type Status
- type Unit
- type UnitFinderProvisioner
- type UnitNotFoundError
- type UnitStatusData
- type UnitStatusProvisioner
- type UpdatableProvisioner
- type UpdateNodeOptions
- type VolumeLabelsOpts
- type VolumeProvisioner
Constants ¶
const ( DefaultHealthcheckScheme = "http" PoolMetadataName = "pool" IaaSIDMetadataName = "iaas-id" IaaSMetadataName = "iaas" )
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") // StatusAsleep is for cases where the unit has been asleep. StatusAsleep = Status("asleep") )
Flow:
+----------------------------------------------+ | | | Start |
+----------+ | +---------+ | | Building | +---------------------+| Stopped | | +----------+ | +---------+ |
^ | ^ | | | | | deploy unit | Stop | | | | | + v RegisterUnit + + +---------+ app unit +----------+ SetUnitStatus +---------+ Sleep +--------+ | Created | +---------> | Starting | +-------------> | Started |+------->| Asleep | +---------+ +----------+ +---------+ +--------+ + ^ + | | | SetUnitStatus | | | | | v | | +-------+ SetUnitStatus | | | Error | +-------------------+ | +-------+ <---------------------+
Variables ¶
var ( LabelAppPool = "app-pool" LabelNodePool = PoolMetadataName )
Functions ¶
func DefaultWebPortEnvs ¶
func ExtendServiceLabels ¶
func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
func InitializeAll ¶
func InitializeAll() error
func IsStartupError ¶
func NodeToJSON ¶
func Register ¶
func Register(name string, pFunc provisionerFactory)
Register registers a new provisioner in the Provisioner registry.
func WebProcessDefaultPort ¶
func WebProcessDefaultPort() string
Types ¶
type ActionLimiter ¶
type AddNodeOptions ¶
type App ¶
type App interface { Named BindUnit(*Unit) error UnbindUnit(*Unit) error // 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]bind.EnvVar GetMemory() int64 GetSwap() int64 GetUpdatePlatform() bool GetRouters() []appTypes.AppRouter GetPool() string GetTeamOwner() string SetQuotaInUse(int) error }
App represents a tsuru app.
It contains only relevant information for provisioning.
type AppFilterProvisioner ¶
AppFilterProvisioner is a provisioner that allows filtering apps by the state of its units.
type BuilderDeploy ¶
BuilderDeploy is a provisioner that allows deploy builded image.
type BuilderDeployDockerClient ¶
type BuilderDeployDockerClient interface { BuilderDeploy GetClient(App) (BuilderDockerClient, error) }
type BuilderDeployKubeClient ¶
type BuilderDeployKubeClient interface { BuilderDeploy GetClient(App) (BuilderKubeClient, error) }
type BuilderDockerClient ¶
type BuilderDockerClient interface { PullAndCreateContainer(opts docker.CreateContainerOptions, w io.Writer) (*docker.Container, string, error) RemoveContainer(opts docker.RemoveContainerOptions) error StartContainer(id string, hostConfig *docker.HostConfig) error StopContainer(id string, timeout uint) error InspectContainer(id string) (*docker.Container, error) CommitContainer(docker.CommitContainerOptions) (*docker.Image, error) DownloadFromContainer(string, docker.DownloadFromContainerOptions) error UploadToContainer(string, docker.UploadToContainerOptions) error AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error) AttachToContainer(opts docker.AttachToContainerOptions) error WaitContainer(id string) (int, error) BuildImage(opts docker.BuildImageOptions) error PushImage(docker.PushImageOptions, docker.AuthConfiguration) error InspectImage(string) (*docker.Image, error) TagImage(string, docker.TagImageOptions) error RemoveImage(name string) error ImageHistory(name string) ([]docker.ImageHistory, error) SetTimeout(timeout time.Duration) }
type BuilderKubeClient ¶
type BuilderKubeClient interface { BuildPod(App, *event.Event, io.Reader, string) (string, error) BuildImage(name, image string, inputStream io.Reader, output io.Writer, ctx context.Context) error ImageTagPushAndInspect(App, string, string) (*docker.Image, string, *provTypes.TsuruYamlData, error) DownloadFromContainer(App, string) (io.ReadCloser, error) }
type CleanImageProvisioner ¶
type ErrUnitStartup ¶
type ErrUnitStartup struct {
Err error
}
func (ErrUnitStartup) Error ¶
func (e ErrUnitStartup) Error() string
func (ErrUnitStartup) IsStartupError ¶
func (e ErrUnitStartup) IsStartupError() bool
type ExecDockerClient ¶
type ExecOptions ¶
type ExecutableProvisioner ¶
type ExecutableProvisioner interface {
ExecuteCommand(opts ExecOptions) error
}
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 InvalidProcessError ¶
type InvalidProcessError struct {
Msg string
}
func (InvalidProcessError) Error ¶
func (e InvalidProcessError) Error() string
type LabelSet ¶
func ImageBuildLabels ¶
func ImageBuildLabels(opts ImageBuildLabelsOpts) *LabelSet
func NodeContainerLabels ¶
func NodeContainerLabels(opts NodeContainerLabelsOpts) *LabelSet
func NodeLabels ¶
func NodeLabels(opts NodeLabelsOpts) *LabelSet
func ProcessLabels ¶
func ProcessLabels(opts ProcessLabelsOpts) (*LabelSet, error)
func ServiceAccountLabels ¶
func ServiceAccountLabels(opts ServiceAccountLabelsOpts) *LabelSet
func ServiceLabels ¶
func ServiceLabels(opts ServiceLabelsOpts) (*LabelSet, error)
func VolumeLabels ¶
func VolumeLabels(opts VolumeLabelsOpts) *LabelSet
func (*LabelSet) AppPlatform ¶
func (*LabelSet) AppProcess ¶
func (*LabelSet) AppReplicas ¶
func (*LabelSet) BuildImage ¶
func (*LabelSet) IsIsolatedRun ¶
func (*LabelSet) NodeIaaSID ¶
func (*LabelSet) NodeMetadata ¶
func (*LabelSet) NodeMetadataNoPrefix ¶
func (*LabelSet) SetBuildImage ¶
func (*LabelSet) SetIsHeadlessService ¶
func (s *LabelSet) SetIsHeadlessService()
func (*LabelSet) SetIsService ¶
func (s *LabelSet) SetIsService()
func (*LabelSet) SetRestarts ¶
func (*LabelSet) SetStopped ¶
func (s *LabelSet) SetStopped()
func (*LabelSet) ToAppSelector ¶
func (*LabelSet) ToIsServiceSelector ¶
func (*LabelSet) ToNodeByPoolSelector ¶
func (*LabelSet) ToNodeContainerSelector ¶
func (*LabelSet) ToNodeSelector ¶
func (*LabelSet) ToSelector ¶
func (*LabelSet) ToVolumeSelector ¶
func (*LabelSet) WithoutAppReplicas ¶
type LocalLimiter ¶
func (*LocalLimiter) Initialize ¶
func (l *LocalLimiter) Initialize(i uint)
func (*LocalLimiter) Len ¶
func (l *LocalLimiter) Len(action string) int
func (*LocalLimiter) Start ¶
func (l *LocalLimiter) Start(action string) func()
type MessageProvisioner ¶
MessageProvisioner is a provisioner that provides a welcome message for logging.
type MongodbLimiter ¶
type MongodbLimiter struct {
// contains filtered or unexported fields
}
func (*MongodbLimiter) Initialize ¶
func (l *MongodbLimiter) Initialize(i uint)
func (*MongodbLimiter) Len ¶
func (l *MongodbLimiter) Len(action string) int
func (*MongodbLimiter) Start ¶
func (l *MongodbLimiter) Start(action string) func()
type Named ¶
type Named interface {
GetName() string
}
Named is something that has a name, providing the GetName method.
type Node ¶
type Node interface { Pool() string IaaSID() string Address() string Status() string // Metadata returns node metadata exclusively managed by tsuru Metadata() map[string]string Units() ([]Unit, error) Provisioner() NodeProvisioner // MetadataNoPrefix returns node metadata managed by tsuru without any // tsuru specific prefix. This can be used with iaas providers. MetadataNoPrefix() map[string]string }
type NodeCheckResult ¶
type NodeContainerLabelsOpts ¶
type NodeExtraData ¶
type NodeHealthChecker ¶
type NodeLabelsOpts ¶
type NodeProvisioner ¶
type NodeProvisioner interface { Named // ListNodes returns a list of all nodes registered in the provisioner. ListNodes(addressFilter []string) ([]Node, error) // GetNode retrieves an existing node by its address. GetNode(address string) (Node, error) // AddNode adds a new node in the provisioner. AddNode(AddNodeOptions) error // RemoveNode removes an existing node. RemoveNode(RemoveNodeOptions) error // UpdateNode can be used to enable/disable a node and update its metadata. UpdateNode(UpdateNodeOptions) error // NodeForNodeData finds a node matching the received NodeStatusData. NodeForNodeData(NodeStatusData) (Node, error) }
type NodeRebalanceProvisioner ¶
type NodeRebalanceProvisioner interface {
RebalanceNodes(RebalanceNodesOptions) (bool, error)
}
type NodeSpec ¶
type NodeSpec struct { // BSON tag for bson serialized compatibility with cluster.Node Address string `bson:"_id"` IaaSID string Metadata map[string]string Status string Pool string Provisioner string }
func NodeToSpec ¶
type NodeStatusData ¶
type NodeStatusData struct { Addrs []string Units []UnitStatusData Checks []NodeCheckResult }
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 ProcessLabelsOpts ¶
type Provisioner ¶
type Provisioner interface { Named // Provision is called when tsuru is creating the app. Provision(App) error // Destroy is called when tsuru is destroying the app. Destroy(App) 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(App, uint, string, io.Writer) error // RemoveUnits "undoes" AddUnits, removing the given number of units // from the app. RemoveUnits(App, uint, string, 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(App, string, 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(App, string) 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(App, string) error // Units returns information about units by App. Units(...App) ([]Unit, error) // RoutableAddresses returns the addresses used to access an application. RoutableAddresses(App) ([]url.URL, error) // Register a unit after the container has been created or restarted. RegisterUnit(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 RemoveNodeOptions ¶
type RollbackableDeployer ¶
RollbackableDeployer is a provisioner that allows rolling back to a previously deployed version.
type ServiceLabelsOpts ¶
type ServiceLabelsOpts struct { App App Process string Replicas int ServiceLabelExtendedOpts }
type SleepableProvisioner ¶
type SleepableProvisioner interface { // Sleep puts the units of the application to sleep, with an optional string // parameter representing the name of the process to sleep. When the // process is empty, Sleep will put all units of the application to sleep. Sleep(App, string) error }
SleepableProvisioner is a provisioner that allows putting applications to sleep.
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 Status Status Address *url.URL Addresses []url.URL }
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(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 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 ¶
UpdatableProvisioner is a provisioner that stores data about applications and must be notified when they are updated
type UpdateNodeOptions ¶
type VolumeLabelsOpts ¶
Directories ¶
Path | Synopsis |
---|---|
Package docker provides a provisioner implementation that use Docker containers.
|
Package docker provides a provisioner implementation that use Docker containers. |
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. |