k8s v0.5.2 K8s.Discovery

Kubernetes API Discovery

Link to this section Summary

Functions

Override the default driver for discovery.

Override default opts for the discovery driver. This is also configurable per K8s.Conn

Discovery the URL for a K8s.Conn and K8s.Operation

Link to this section Functions

Link to this function

default_driver()

default_driver() :: module()

Override the default driver for discovery.

Each K8s.Conn can have its own driver set. If unset, this value will be used.

Defaults to K8s.Discovery.Driver.HTTP

Example mix config

In the example below dev and test clusters will use the File driver, while prod will use the HTTP driver.

use Mix.Config

config :k8s,
  discovery_driver: K8s.Discovery.Driver.File,
  discovery_opts: [config: "test/support/discovery/example.json"],

  clusters: %{
    test: %{
      conn: "test/support/kube-config.yaml"
    },
    dev: %{
      conn: "test/support/kube-config.yaml"
    },
    prod: %{
      conn: "test/support/kube-config.yaml",
      conn_opts: [
        discovery_driver: K8s.Discovery.Driver.HTTP
      ]
    }
  }
Link to this function

default_opts()

default_opts() :: Keyword.t()

Override default opts for the discovery driver. This is also configurable per K8s.Conn

Link to this function

url_for(conn, op)

url_for(K8s.Conn.t(), K8s.Operation.t()) ::
  {:ok, String.t()} | {:error, atom(), binary()}

Discovery the URL for a K8s.Conn and K8s.Operation

Examples

iex> conn = K8s.Conn.from_file("./test/support/kube-config.yaml")
...> op = K8s.Operation.build(:get, "apps/v1", :deployments, [namespace: "default", name: "nginx"])
...> K8s.Discovery.url_for(conn, op)
{:ok, "https://localhost:6443/apis/apps/v1/namespaces/default/deployments/nginx"}