k8s v0.5.0-rc.2 K8s.Client.Runner.Base
Base HTTP processor for K8s.Client
Link to this section Summary
Functions
Runs a K8s.Operation
.
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
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, binary()}
Link to this section Functions
Runs a K8s.Operation
.
Examples
Note: Examples assume a K8s.Conn
was configured named :test
. See K8s.Conn.Config
.
Running a list pods operation:
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 = K8s.Client.create(deployment)
conn = K8s.Conn.lookup(:tes)
# opts is passed to HTTPoison as opts.
opts = [params: %{"dryRun" => "all"}]
:ok = K8s.Client.Runner.Base.run(operation, conn, opts)
Link to this function
run(operation, conn, opts)
run(K8s.Operation.t(), K8s.Conn.t(), keyword()) :: result_t()
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(K8s.Operation.t(), K8s.Conn.t(), map(), keyword()) :: result_t()
Run an operation with an HTTP Body (map) and pass opts
to HTTPoison.
See run/2