View Source K8s.Client.Runner.Base (k8s v2.6.1)
Base HTTP processor for K8s.Client
.
Summary
Functions
Runs a K8s.Operation
.
Run a connect operation and pass websocket_driver_opts
to K8s.Client.WebSocketProvider
See run/3
Runs a K8s.Operation
and streams the response.
Runs a K8s.Operation
and streams the response.
Types
Acceptable HTTP body types
@type error_t() :: {:error, K8s.Middleware.Error.t()} | {:error, K8s.Operation.Error.t()} | {:error, K8s.Client.APIError.t()} | {:error, K8s.Discovery.Error.t()} | {:error, atom()} | {:error, binary()}
Functions
@spec run(K8s.Operation.t()) :: 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.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)
@spec run(K8s.Conn.t(), K8s.Operation.t()) :: result_t()
@spec run( K8s.Operation.t(), keyword() ) :: result_t()
@spec run(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: result_t()
Run a connect operation and pass websocket_driver_opts
to K8s.Client.WebSocketProvider
See run/3
@spec stream(K8s.Conn.t(), K8s.Operation.t(), keyword()) :: K8s.Client.Provider.stream_response_t()
Runs a K8s.Operation
and streams the response.
@spec stream_to(K8s.Conn.t(), K8s.Operation.t(), keyword(), pid()) :: K8s.Client.Provider.stream_to_response_t()
Runs a K8s.Operation
and streams the response.