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

Base HTTP processor for K8s.Client.

Link to this section Summary

Types

Acceptable HTTP body types

Link to this section 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, atom()}
  | {:error, binary()}
@type result_t() :: {:ok, map() | reference()} | error_t()

Link to this section Functions

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

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
@spec run(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: result_t()

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