bonny v0.4.1 DeploymentEventLogController.WatchServer

Controller watcher implementation

Link to this section Summary

Functions

Callback implementation for Bonny.Server.Watcher.add/1.

Returns a specification to start this module under a supervisor.

Callback implementation for Bonny.Server.Watcher.delete/1.

Callback implementation for Bonny.Server.Watcher.modify/1.

Link to this section Functions

Callback implementation for Bonny.Server.Watcher.add/1.

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete(resource)

Callback implementation for Bonny.Server.Watcher.delete/1.

Link to this function

modify(resource)

Callback implementation for Bonny.Server.Watcher.modify/1.

Link to this function

start_link(opts)

Link to this function

watch_operation()

K8s.Operation to watch.

Examples

Log all pod lifecycle events

    defmodule PodLifecycleLogger do
      use Bonny.Server.Watcher

      @impl true
      def watch_operation() do
        K8s.Client.list("v1", :pods, namespace: :all)
      end

      @impl true
      def add(pod) do
        log_event(:add, pod)
      end

      @impl true
      def modify(pod) do
        log_event(:modify, pod)
      end

      @impl true
      def delete(pod) do
        log_event(:delete, pod)
      end

      @spec log_event(atom, map) :: :ok
      def log_event(type, pod) do
        name = get_in(pod, ["metadata", "name"])
        namespace = get_in(pod, ["metadata", "namepace"]) || "default"
        # log type,name,namespace here
      end
    end

Callback implementation for Bonny.Server.Watcher.watch_operation/0.