Bonny.Controller behaviour (bonny v1.5.0)

Copy Markdown View Source

Bonny.Controller defines controller behaviours and generates boilerplate for generating Kubernetes manifests.

A custom controller is a controller that users can deploy and update on a running cluster, independently of the cluster’s own lifecycle. Custom controllers can work with any kind of resource, but they are especially effective when combined with custom resources. The Operator pattern is one example of such a combination. It allows developers to encode domain knowledge for specific applications into an extension of the Kubernetes API.

Controllers allow for simple add, modify, delete, and reconcile handling of custom resources in the Kubernetes API.

Summary

Callbacks

Bonny.Controller comes with a default implementation which returns Bonny.Config.config()

Should return an operation to list resources for watching and reconciliation.

Callbacks

add(map)

@callback add(map()) :: :ok | :error

conn()

@callback conn() :: K8s.Conn.t()

Bonny.Controller comes with a default implementation which returns Bonny.Config.config()

delete(map)

@callback delete(map()) :: :ok | :error

list_operation()

@callback list_operation() :: K8s.Operation.t()

Should return an operation to list resources for watching and reconciliation.

Bonny.Controller comes with a default implementation

modify(map)

@callback modify(map()) :: :ok | :error

reconcile(map)

@callback reconcile(map()) :: :ok | :error

Functions

ensure_list_query(op)

ensure_watch_query(op)

list_operation(controller)

@spec list_operation(module()) :: K8s.Operation.t()