Documentation
¶
Overview ¶
Package operator implements a Kubernetes controller to reconcile Operator CRD resources.
Package operator implements the top-level Operator controller that manages the lifecycle of declarative controller specifications.
The operator watches Operator custom resources and creates/manages the corresponding Δ-controllers based on their specifications. It provides the bridge between declarative YAML specifications and the imperative controller runtime.
Key components:
- Operator: Main operator that manages controller lifecycles.
- OperatorController: Kubernetes controller that reconciles Operator CRs.
The operator supports:
- Dynamic controller creation from Operator CRs.
- Lifecycle management (create, update, delete controllers).
- Status reporting for managed controllers.
- Optional API server integration for view object access.
- Error handling and recovery.
Example usage:
op, _ := operator.NewFromFile("my-op", mgr, "operator.yaml", operator.Options{
APIServer: server,
Logger: logger,
})
return mgr.Add(op)
Index ¶
- Constants
- type Controller
- type Operator
- func (op *Operator) AddController(config opv1a1.Controller) error
- func (op *Operator) GetController(name string) *dcontroller.Controller
- func (op *Operator) GetManager() runtimeMgr.Manager
- func (op *Operator) GetName() string
- func (op *Operator) GetStatus(gen int64) opv1a1.OperatorStatus
- func (op *Operator) RegisterGVKs() error
- func (op *Operator) Start(ctx context.Context) error
- func (op *Operator) Trigger(err error)
- type Options
Constants ¶
const StatusChannelBufferSize = 64
StatusChannelBufferSize defines the longest backlog on the status channel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface {
runtimeManager.Runnable
reconcile.Reconciler
GetManager() runtimeManager.Manager
GetClient() client.Client
SetAPIServer(*apiserver.APIServer)
}
Controller definition.
func NewController ¶
func NewController(config *rest.Config, options runtimeManager.Options) (Controller, error)
NewController creates a new Kubernetes controller that handles the Operator CRDs.
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
Operator definition.
func New ¶
func New(name string, mgr runtimeMgr.Manager, spec *opv1a1.OperatorSpec, opts Options) *Operator
New creates a new operator.
func NewFromFile ¶
NewFromFile creates a new operator from a serialized operator spec.
func (*Operator) AddController ¶
func (op *Operator) AddController(config opv1a1.Controller) error
AddController adds a new controller to the operator.
func (*Operator) GetController ¶
func (op *Operator) GetController(name string) *dcontroller.Controller
GetController returns the controller with the given name or nil if no controller with that name exists.
func (*Operator) GetManager ¶
func (op *Operator) GetManager() runtimeMgr.Manager
GetManager returns the controller runtime manager associated with the operator.
func (*Operator) GetStatus ¶
func (op *Operator) GetStatus(gen int64) opv1a1.OperatorStatus
GetStatus populates the operator status with the controller statuses.
func (*Operator) RegisterGVKs ¶
RegisterGVKs registers the view resources associated with the conbtrollers run by operator in the extension API server.
type Options ¶
type Options struct {
// API server is an optional extension server that can be used to interact with the view
// objects stored in the operator cacache.
APIServer *apiserver.APIServer
// ErrorChannel is a channel to receive errors from the operator. Note that the error
// channel is rate limited to at most 3 errors per every 2 seconds. Use ReportErrors on the
// individual controllers to get the errors that might have been supporessed by the rate
// limiter.
ErrorChannel chan error
// Logger is a standard logger.
Logger logr.Logger
}
Options can be used to customize the Operator's behavior.