View Source K8s.Client.Runner.Base (k8s v2.6.1)

Base HTTP processor for K8s.Client.

Summary

Types

Acceptable HTTP body types

Functions

Run a connect operation and pass websocket_driver_opts to K8s.Client.WebSocketProvider See run/3

Runs a K8s.Operation and streams the response.

Types

@type body_t() :: [map()] | map() | binary() | nil

Acceptable HTTP body types

@type error_t() ::
  {:error, K8s.Middleware.Error.t()}
  | {:error, K8s.Operation.Error.t()}
  | {:error, K8s.Client.APIError.t()}
  | {:error, K8s.Discovery.Error.t()}
  | {:error, atom()}
  | {:error, binary()}
@type result_t() :: {:ok, map() | reference()} | error_t()

Functions

@spec run(K8s.Operation.t()) :: result_t()

Runs a K8s.Operation.

Examples

Note: Examples assume a K8s.Conn was configured named "test". See K8s.Conn.Config.

Running a list pods operation:

{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
operation = K8s.Client.list("v1", "Pod", namespace: :all)
{:ok, %{"items" => pods}} = K8s.Client.run(conn, operation)

Running a dry-run of a create deployment operation:

deployment = %{
  "apiVersion" => "apps/v1",
  "kind" => "Deployment",
  "metadata" => %{
    "labels" => %{
      "app" => "nginx"
    },
    "name" => "nginx",
    "namespace" => "test"
  },
  "spec" => %{
    "replicas" => 2,
    "selector" => %{
      "matchLabels" => %{
        "app" => "nginx"
      }
    },
    "template" => %{
      "metadata" => %{
        "labels" => %{
          "app" => "nginx"
        }
      },
      "spec" => %{
        "containers" => %{
          "image" => "nginx",
          "name" => "nginx"
        }
      }
    }
  }
}

operation =
  deployment
  |> K8s.Client.create()
  |> K8s.Operation.put_query_param(:dryRun, "all")

{:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
{:ok, result} = K8s.Client.Runner.Base.run(conn, operation)
@spec run(K8s.Conn.t(), K8s.Operation.t()) :: result_t()
@spec run(
  K8s.Operation.t(),
  keyword()
) :: result_t()
Link to this function

run(conn, operation, http_opts)

View Source
@spec run(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: result_t()

Run a connect operation and pass websocket_driver_opts to K8s.Client.WebSocketProvider See run/3

Link to this function

stream(conn, operation, http_opts)

View Source

Runs a K8s.Operation and streams the response.

Link to this function

stream_to(conn, operation, http_opts, stream_to)

View Source

Runs a K8s.Operation and streams the response.