View Source Datapio.Controller behaviour (Datapio OpenCore v0.1.0)
Behaviour used to implement a Kubernetes operator.
Example:
defmodule MyApp.MyOperator do
use Datapio.Controller,
api_version: "v1"
kind: "Pod"
@impl true
def add(pod, _opts) do
:ok
end
@impl true
def modify(pod, _opts) do
:ok
end
@impl true
def delete(pod, _opts) do
:ok
end
@impl true
def reconcile(pod, _opts) do
:ok
end
end
Link to this section Summary
Types
Options passed to the controller's callbacks
Default options
Option passed to start_link/2
Option controlling how the Datapio.Controller
should be supervised
Option controlling what Kubernetes resources are watched
Functions
Returns a specification to start this module under a supervisor.
Start a controller linked to the current process
Link to this section Types
Specs
controller_options() :: keyword()
Options passed to the controller's callbacks
Specs
module_option() :: watch_option() | {:schema, schema()} | {:supervisor, supervisor_options()}
Default options
Specs
module_options() :: [module_option(), ...]
Specs
resource() :: Datapio.K8s.Resource.resource()
Specs
schema() :: Datapio.K8s.Resource.schema()
Specs
start_option() :: watch_option() | {:options, controller_options()}
Option passed to start_link/2
Specs
start_options() :: [start_option(), ...]
Specs
supervisor_option() :: {:restart, :temporary | :transient | :permanent} | {:shutdown, timeout() | :brutal_kill}
Option controlling how the Datapio.Controller
should be supervised
Specs
supervisor_options() :: [supervisor_option()]
Specs
watch_option() :: {:api_version, String.t()} | {:kind, String.t()} | {:namespace, :all | String.t()} | {:reconcile_delay, non_neg_integer()}
Option controlling what Kubernetes resources are watched
Link to this section Callbacks
Specs
add(resource(), controller_options()) :: :ok | {:error, term()}
Specs
delete(resource(), controller_options()) :: :ok | {:error, term()}
Specs
modify(resource(), controller_options()) :: :ok | {:error, term()}
Specs
reconcile(resource(), controller_options()) :: :ok | {:error, term()}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
start_link(module(), start_options()) :: GenServer.on_start()
Start a controller linked to the current process