Documentation ¶
Index ¶
- func RecoverStores(ctx context.Context, stores []Store) error
- func RunControllers(ctx context.Context, controllers []Controller) error
- func ShutdownRunnables(ctx context.Context, controllers []Runnable)
- func StartWebhooksAndWait(ctx context.Context, webhooks []Webhook) error
- type BaseManager
- func (m *BaseManager) Add(runnables ...Runnable)
- func (m *BaseManager) GetHealth() []HealthStatus
- func (m *BaseManager) GetReadiness() error
- func (m *BaseManager) IsStarted() bool
- func (m *BaseManager) IsStarting() bool
- func (m *BaseManager) ShutdownAndWait(ctx context.Context)
- func (m *BaseManager) Start(ctx context.Context) error
- type Controller
- type ControllerManager
- func (m *ControllerManager) Add(runnables ...Runnable)
- func (m *ControllerManager) AddStore(stores ...Store)
- func (m *ControllerManager) GetHealth() []HealthStatus
- func (m *ControllerManager) ShutdownAndWait(ctx context.Context)
- func (m *ControllerManager) Start(ctx context.Context, startTimeout time.Duration) error
- type HealthStatus
- type Runnable
- type Store
- type Webhook
- type WebhookManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecoverStores ¶
RecoverStores recovers all stores in the background and blocks until all of them have finished recovering.
func RunControllers ¶
func RunControllers(ctx context.Context, controllers []Controller) error
RunControllers starts all the given Controllers in the background and blocks until all of them are started. If any controller's Run method returns an error, this method returns and cancels all other runs. if the context is canceled, it will cancel starting up.
func ShutdownRunnables ¶
ShutdownRunnables stops all runnables and blocks until they return.
func StartWebhooksAndWait ¶
StartWebhooksAndWait starts all the given Webhooks in the background and blocks until they are all ready. If any controller's Start method returns an error, this method returns and cancels the context. To terminate controllers, cancel the passed context.
Types ¶
type BaseManager ¶
type BaseManager struct {
// contains filtered or unexported fields
}
BaseManager is the base manager that manages runnables, readiness and liveness status.
func NewBaseManager ¶
func NewBaseManager(ctrlContext controllercontext.Context) *BaseManager
func (*BaseManager) Add ¶
func (m *BaseManager) Add(runnables ...Runnable)
Add a new runnable to the manager to be managed. Will not take effect once Start is called.
func (*BaseManager) GetHealth ¶
func (m *BaseManager) GetHealth() []HealthStatus
GetHealth returns a list of all health statuses. This has to be overridden, and returns an empty slice by default.
func (*BaseManager) GetReadiness ¶
func (m *BaseManager) GetReadiness() error
GetReadiness returns an error if the base manager is not yet fully initialized.
func (*BaseManager) IsStarted ¶ added in v0.1.0
func (m *BaseManager) IsStarted() bool
func (*BaseManager) IsStarting ¶ added in v0.1.0
func (m *BaseManager) IsStarting() bool
func (*BaseManager) ShutdownAndWait ¶
func (m *BaseManager) ShutdownAndWait(ctx context.Context)
type Controller ¶
type Controller interface { Runnable // Run should block until it terminates; if there is an error, it should return // one. If the context is canceled, it should return the context's error in a // timely fashion. Run(ctx context.Context) error // GetHealth returns the health status of the Controller. GetHealth() HealthStatus }
Controller encapsulates a routine that can be run and shut down.
type ControllerManager ¶
type ControllerManager struct { *BaseManager // contains filtered or unexported fields }
ControllerManager performs a high-level management of multiple controllers and also optionally performs leader election.
func NewControllerManager ¶ added in v0.1.0
func NewControllerManager( ctrlContext controllercontext.Context, ctrlCfg configv1alpha1.ControllerManagerConfigSpec, defaultLeaseName string, ) (*ControllerManager, error)
func (*ControllerManager) Add ¶
func (m *ControllerManager) Add(runnables ...Runnable)
Add a new runnable to the controller manager to be managed. Will not take effect once Start is called.
func (*ControllerManager) AddStore ¶
func (m *ControllerManager) AddStore(stores ...Store)
AddStore adds a new Store to be recovered. Will not take effect once Start is called.
func (*ControllerManager) GetHealth ¶
func (m *ControllerManager) GetHealth() []HealthStatus
GetHealth returns a list of all controllers' health statuses.
func (*ControllerManager) ShutdownAndWait ¶
func (m *ControllerManager) ShutdownAndWait(ctx context.Context)
func (*ControllerManager) Start ¶
Start will start up all controllers and blocks until all of them are started and ready. This method will first block until elected, and once elected it will block until the controllers are fully started.
If there is an error in starting, this method returns an error. When the context is canceled, all controllers should stop their start process as well.
type HealthStatus ¶
type Webhook ¶
type Webhook interface { Runnable // Name of the webhook. Name() string // Start blocks until the webhook is ready. Once the method returns, it is // assumed to be Ready. If the context is canceled, Start should return timely // with the context error. Start(ctx context.Context) error // Ready specifies if the webhook is ready to receive requests. Ready() bool // Path of the webhook. Path() string // Handle the incoming request and returns a response. Handle(ctx context.Context, req *admissionv1.AdmissionRequest) (*admissionv1.AdmissionResponse, error) }
type WebhookManager ¶
type WebhookManager struct { *BaseManager // contains filtered or unexported fields }
WebhookManager takes care of the lifecycles of webhooks, and the liveness and readiness status of the server.
func NewWebhookManager ¶
func NewWebhookManager(ctrlContext controllercontext.Context) *WebhookManager
func (*WebhookManager) Add ¶
func (m *WebhookManager) Add(runnables ...Runnable)
Add a new runnable to the webhook manager to be managed. Will not take effect once Start is called.