k8s v0.5.2 K8s.Client.Runner.Base

Base HTTP processor for K8s.Client

Link to this section Summary

Types

Acceptable HTTP body types

Functions

Run an operation and pass opts to HTTPoison. Destructures Operation data and passes as the HTTP body.

Run an operation with an HTTP Body (map) and pass opts to HTTPoison. See run/2

Link to this section Types

Link to this type

body_t()

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

Acceptable HTTP body types

Link to this type

result_t()

result_t() ::
  {:ok, map() | reference()}
  | {:error, K8s.Middleware.Error.t()}
  | {:error, :connection_not_registered}
  | {:error, :missing_required_param}
  | {:error, atom()}
  | {:error, binary()}

Link to this section Functions

Link to this function

run(operation, conn)

run(K8s.Operation.t(), K8s.Conn.t() | nil) :: 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.lookup(:test)
operation = K8s.Client.list("v1", "Pod", namespace: :all)
{:ok, %{"items" => pods}} = K8s.Client.run(operation, conn)

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.lookup(:test)  
{:ok, result} = K8s.Client.Runner.Base.run(operation, conn)
Link to this function

run(operation, conn, opts)

Run an operation and pass opts to HTTPoison. Destructures Operation data and passes as the HTTP body.

See run/2

Link to this function

run(operation, conn, body, opts \\ [])

Run an operation with an HTTP Body (map) and pass opts to HTTPoison. See run/2