View Source K8s.Client.Runner.Base (k8s v1.1.1)

Base HTTP processor for K8s.Client.

Link to this section Summary

Types

Acceptable HTTP body types

Link to this section Types

Specs

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

Acceptable HTTP body types

Specs

error_t() ::
  {:error, K8s.Middleware.Error.t()}
  | {:error, K8s.Operation.Error.t()}
  | {:error, atom()}
  | {:error, binary()}

Specs

result_t() :: {:ok, map() | reference()} | error_t()

Link to this section Functions

Specs

Runs a K8s.Operation.

examples

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)
Link to this function

run(conn, operation, http_opts)

View Source

Specs

Run an operation and pass http_opts to K8s.Client.HTTPProvider See run/2