k8s v0.5.2 K8s.Conn

Handles authentication and connection configuration details for a Kubernetes cluster.

Connections can be registered via Mix.Config or environment variables.

Connections can also be dynamically built during application runtime.

Link to this section Summary

Functions

Reads configuration details from a kubernetes config file.

Generates configuration from kubernetes service account.

List of all registered connections. Connections are registered via Mix.Config or env variables.

Lookup a registered connection by name. See K8s.Conn.Config.

Link to this section Types

Link to this type

t()

t() :: %K8s.Conn{
  auth: auth_t(),
  ca_cert: String.t() | nil,
  cluster_name: atom(),
  discovery_driver: module(),
  discovery_opts: Keyword.t(),
  insecure_skip_tls_verify: boolean(),
  url: String.t(),
  user_name: String.t() | nil
}

Link to this section Functions

Link to this function

from_file(config_file, opts \\ [])

from_file(binary(), keyword()) :: t()

Reads configuration details from a kubernetes config file.

Defaults to current-context.

Options

  • context sets an alternate context
  • cluster set or override the cluster read from the context
  • user set or override the user read from the context
  • discovery_driver module name to use for discovery
  • discovery_opts options for discovery module
Link to this function

from_service_account()

from_service_account() :: t()

Generates configuration from kubernetes service account.

kubernetes.io :: Accessing the API from a Pod

Link to this function

from_service_account(cluster_name)

from_service_account(atom()) :: t()
Link to this function

from_service_account(cluster_name, root_sa_path)

from_service_account(atom(), String.t()) :: t()
Link to this function

list()

list() :: [t()]

List of all registered connections. Connections are registered via Mix.Config or env variables.

Examples

K8s.Conn.list()
[%K8s.Conn{ca_cert: nil, auth: %K8s.Conn.Auth{}, cluster_name: :"docker-for-desktop-cluster", discovery_driver: K8s.Discovery.Driver.File, discovery_opts: [config: "test/support/discovery/example.json"], insecure_skip_tls_verify: true, url: "https://localhost:6443", user_name: "docker-for-desktop"}]
Link to this function

lookup(cluster_name)

lookup(atom()) :: {:ok, t()} | {:error, :connection_not_registered}

Lookup a registered connection by name. See K8s.Conn.Config.

Examples

K8s.Conn.lookup(:test)
{:ok, %K8s.Conn{ca_cert: nil, auth: %K8s.Conn.Auth{}, cluster_name: :"docker-for-desktop-cluster", discovery_driver: K8s.Discovery.Driver.File, discovery_opts: [config: "test/support/discovery/example.json"], insecure_skip_tls_verify: true, url: "https://localhost:6443", user_name: "docker-for-desktop"}}