View Source K8s.Client.Runner.Watch (k8s v1.1.1)
K8s.Client
runner that will watch a resource or resources and stream results back to a process.
Link to this section Summary
Functions
Watch a resource or list of resources. Provide the stream_to
option or results will be stream to self()
.
Watch a resource or list of resources from a specific resource version. Provide the stream_to
option or results will be stream to self()
.
Watches resources and returns an Elixir Stream of events emmitted by kubernetes.
Link to this section Functions
Specs
get_resource_version(K8s.Conn.t(), K8s.Operation.t()) :: {:ok, binary()} | K8s.Client.Runner.Base.error_t()
Specs
run(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: K8s.Client.Runner.Base.result_t()
Watch a resource or list of resources. Provide the stream_to
option or results will be stream to self()
.
Note: Current resource version will be looked up automatically.
examples
Examples
{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
operation = K8s.Client.list("v1", "Namespace")
{:ok, reference} = Watch.run(conn, operation, stream_to: self())
{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
operation = K8s.Client.get("v1", "Namespace", [name: "test"])
{:ok, reference} = Watch.run(conn, operation, stream_to: self())
Specs
run(K8s.Conn.t(), K8s.Operation.t(), binary(), keyword()) :: K8s.Client.Runner.Base.result_t()
Watch a resource or list of resources from a specific resource version. Provide the stream_to
option or results will be stream to self()
.
examples
Examples
{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
operation = K8s.Client.list("v1", "Namespace")
resource_version = 3003
{:ok, reference} = Watch.run(conn, operation, resource_version, stream_to: self())
{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
operation = K8s.Client.get("v1", "Namespace", [name: "test"])
resource_version = 3003
{:ok, reference} = Watch.run(conn, operation, resource_version, stream_to: self())
Specs
stream(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: {:ok, Enumerable.t()} | {:error, K8s.Operation.Error.t()}
Watches resources and returns an Elixir Stream of events emmitted by kubernetes.
example
Example
{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
op = K8s.Client.list("v1", "Namespace")
K8s.Client.Runner.Watch.stream(conn, op) |> Stream.map(&IO.inspect/1) |> Stream.run()