View Source K8s.Client.Runner.Base (k8s v1.1.1)
Base HTTP processor for K8s.Client
.
Link to this section Summary
Functions
Runs a K8s.Operation
.
Run an operation and pass http_opts
to K8s.Client.HTTPProvider
See run/2
Link to this section Types
Specs
Acceptable HTTP body types
Specs
error_t() :: {:error, K8s.Middleware.Error.t()} | {:error, K8s.Operation.Error.t()} | {:error, atom()} | {:error, binary()}
Specs
Link to this section Functions
Specs
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)
Specs
run(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: result_t()
Run an operation and pass http_opts
to K8s.Client.HTTPProvider
See run/2