Skip to content

Instantly share code, notes, and snippets.

@coryodaniel
Last active June 21, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coryodaniel/f889a309f4ea06b8e7f8316c6b299716 to your computer and use it in GitHub Desktop.
Save coryodaniel/f889a309f4ea06b8e7f8316c6b299716 to your computer and use it in GitHub Desktop.
K8s.Controller to k8s client?
# Thinking about moving controller functionality from Bonny to K8s.
# Currently k8s is very focused around HTTP, but controllers are a common concept, so YMMV.
# This may be a piece of yarn, and end up pulling too much operator functionality.
# In that case, I'm using this for spit balling the API for Bonny v1.
# Start a new controller w/ default
K8s.Controller.start("foo.example.com/v1", :bars, mod: BarController)
K8s.Controller.start("foo.example.com/v1", :bars,
mod: BarController,
cluster: :default,
namespace: "foo", # if applicable support :all?
label_selectors: %{},
field_selectors: %{},
reconcile_every: 30 # seconds
)
# Options:
# - handler module
# - reconcile every
# - cluster name (for Discovery)
# - namespace
# - labelSelectors and fieldSelectors to narrow a controller to specific
defmodule K8s.Controller do
# Adds @behaviour and overridable add/1, modify/1, delete/1, reconcile/1 functions
defmacro __using__(_), do: nil
def start(groupVersion, kind, opts) do
# spawns a linked process to watch/reconcile
end
end
K8s.Controller.start("foo.example.com/v1", :bars, mod: BarController)
defmodule BarController do
use K8s.Controller
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment