Documentation
¶
Overview ¶
Package operator is the top-level Operator abstraction that implement the declarative controller specifications.
The operator creates/manages the corresponding Δ-controllers based on their specifications. It provides the bridge between declarative YAML specifications and the imperative controller runtime.
Example usage:
op, _ := operator.NewFromFile("my-op", mgr, "operator.yaml", operator.Options{ APIServer: server, Logger: logger, })
Index ¶
- Constants
- type Group
- func (g *Group) AddOperator(name string, spec *opv1a1.OperatorSpec) (*Operator, error)
- func (g *Group) DeleteOperator(name string)
- func (g *Group) GetClient() client.Client
- func (g *Group) GetErrorChannel() chan error
- func (g *Group) GetOperator(name string) *Operator
- func (g *Group) SetAPIServer(apiServer *apiserver.APIServer)
- func (g *Group) Start(ctx context.Context) error
- func (g *Group) UpsertOperator(name string, spec *opv1a1.OperatorSpec) (*Operator, error)
- 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) ListControllers() []*dcontroller.Controller
- func (op *Operator) RegisterGVKs() error
- func (op *Operator) SetAPIServer(apiServer *apiserver.APIServer)
- func (op *Operator) Start(ctx context.Context) 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 Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a set of operators that share the same lifecycle and a common APIServer
func (*Group) AddOperator ¶
AddOperator registers an operator with the group.
func (*Group) DeleteOperator ¶
func (*Group) GetClient ¶
GetClient returns a controller runtime client that multiplexes all registered operator clients.
func (*Group) GetErrorChannel ¶
GetErrorChannel returns the error channel the group uses to surface errors.
func (*Group) GetOperator ¶
GetOperator returns the operator with the given name.
func (*Group) SetAPIServer ¶
SetAPIServer allows to set the embedded API server shared by the operatos for this group. The API server lifecycle is not managed by the operator; make sure to run apiServer.Start before calling Start on the oparator group.
func (*Group) UpsertOperator ¶
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) ListControllers ¶
func (op *Operator) ListControllers() []*dcontroller.Controller
ListControllers lists the controllers for the operator.
func (*Operator) RegisterGVKs ¶
RegisterGVKs registers the view resources associated with the conbtrollers run by operator in the extension API server.
func (*Operator) SetAPIServer ¶
SetAPIServer allows to set the embedded API server. The API server lifecycle is not managed by the operator; make sure to run apiServer.Start before calling Start on the oparator.
type Options ¶
type Options struct { // 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 // 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 // Logger is a standard logger. Logger logr.Logger }
Options can be used to customize the Operator's behavior.