View Source K8s.Client.WebSocketProvider (k8s v1.2.0)

Websocket client for k8s API.

Link to this section Summary

Functions

Make a connection to the K8s API and upgrade to a websocket. This is useful for streaming resources like /exec, /logs, /attach

Link to this section Functions

Link to this function

request(url, insecure, ssl_options, cacerts, headers, opts)

View Source
@spec request(
  String.t(),
  boolean(),
  keyword(atom()),
  keyword(binary()),
  keyword(tuple()),
  keyword(atom())
) :: {:ok, pid()} | {:error, binary()}

Make a connection to the K8s API and upgrade to a websocket. This is useful for streaming resources like /exec, /logs, /attach

example

Example

url = "https://localhost:6443/api/v1/namespaces/test/pods/nginx-pod/exec?command=%2Fbin%2Fsh&command=-c&command=date&stdin=true&stderr=true&stdout=true&tty=true"
insecure = false
ssl_options = [cert: <<1,2>>, key: {:RSAPrivateKey, <<48, 130>>}, verify: :verify_none]
cacerts = [<<1,2,3>>,<1,2,3>>]
headers = [{"Accept", "*/*"}, {"Content-Type", "application/json"}]
opts = [command    : ["/bin/sh", "-c", "date"], stdin: true, stderr: true, stdout: true, tty: true, stream_to: #PID<0.271.0>]
{:ok, pid} = K8s.Client.WebSocketProvider.request(url, ssl_options, cacerts, headers, opts)