k8s v0.2.5 K8s.Client.Runner.Base

Base HTTP processor for K8s.Client

Link to this section Summary

Functions

Run an operation and pass opts to HTTPoison.

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

Link to this section Types

Link to this type

result()
result() :: {:ok, map() | reference()} | {:error, atom()} | {:error, binary()}

Link to this section Functions

Link to this function

encode(body, http_method)
encode(any(), atom()) :: {:ok, binary()} | {:error, any()}

Link to this function

run(operation, cluster_name \\ "default")
run(K8s.Operation.t(), nil | binary() | atom()) :: result()

Runs a K8s.Operation.

Examples

Note: Examples assume a cluster was registered named "test-cluster", see K8s.Cluster.register/2.

Running a list pods operation:

operation = K8s.Client.list("v1", "Pod", namespace: :all)
{:ok, %{"items" => pods}} = K8s.Client.run(operation, "test-cluster")

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 = K8s.Client.create(deployment)

# opts is passed to HTTPoison as opts.
opts = [params: %{"dryRun" => "all"}]
:ok = K8s.Client.Runner.Base.run(operation, "test-cluster", opts)
Link to this function

run(operation, cluster_name, opts)
run(K8s.Operation.t(), binary() | atom(), keyword()) :: result()

Run an operation and pass opts to HTTPoison.

See run/2

Link to this function

run(operation, cluster_name, body, opts \\ [])
run(K8s.Operation.t(), binary() | atom(), map(), keyword()) :: result()

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