k8s v0.3.0 K8s.Config
Add runtime cluster configuration with environment variables.
Each variable consists of a prefix that determines where the value will be placed in the config and a suffix that is the cluster name. The cluster name will be atomized.
Environment Variable Prefixes:
K8S_CLUSTER_CONF_SA_
- boolean enables authentication to the k8s API with the podsspec.serviceAccountName
.K8S_CLUSTER_CONF_PATH_
- string absolute path to the kube config file.K8S_CLUSTER_CONF_CONTEXT_
string which context to use in the kube config file.
Examples
export K8S_CLUSTER_CONF_SA_us_central=true
export K8S_CLUSTER_CONF_PATH_us_east="east.yaml"
export K8S_CLUSTER_CONF_CONTEXT_us_east="east"
export K8S_CLUSTER_CONF_PATH_us_west="west.yaml"
export K8S_CLUSTER_CONF_CONTEXT_us_west="west"
Link to this section Summary
Functions
Returns runtime and compile time cluster configuration merged together.
Discovery HTTP call timeouts in ms for each API endpoint. API endpoints are discovered in parallel. This controls the timeout for any given HTTP request.
Subset of env vars applicable to k8s
Cluster configuration read from env variables.
To be merged over Application.get_env(:k8s, :clusters)
.
Link to this section Functions
clusters()
clusters() :: map()
clusters() :: map()
Returns runtime and compile time cluster configuration merged together.
discovery_http_timeout(cluster_name)
discovery_http_timeout(atom() | binary()) :: pos_integer()
discovery_http_timeout(atom() | binary()) :: pos_integer()
Discovery HTTP call timeouts in ms for each API endpoint. API endpoints are discovered in parallel. This controls the timeout for any given HTTP request.
Examples
export K8S_DISCOVERY_TIMEOUT_us_central=10000
env()
env() :: map()
env() :: map()
Subset of env vars applicable to k8s
runtime_clusters_config(env_vars, config)
Cluster configuration read from env variables.
To be merged over Application.get_env(:k8s, :clusters)
.
Examples
Overriding compile time configs
iex> env = %{"K8S_CLUSTER_CONF_PATH_dev" => "runtime/path/to/dev.conf"}
...> compile_config = %{dev: %{conf: "compiletime/path/to/dev.conf"}}
...> K8s.Config.runtime_clusters_config(env, compile_config)
%{dev: %{conf: "runtime/path/to/dev.conf"}}
Merging compile time configs
iex> env = %{"K8S_CLUSTER_CONF_CONTEXT_dev" => "runtime-context"}
...> compile_config = %{dev: %{conf: "compiletime/path/to/dev.conf"}}
...> K8s.Config.runtime_clusters_config(env, compile_config)
%{dev: %{conf: "compiletime/path/to/dev.conf", conf_opts: [context: "runtime-context"]}}
Adding clusters at runtime
iex> env = %{"K8S_CLUSTER_CONF_PATH_us_east" => "runtime/path/to/us_east.conf", "K8S_CLUSTER_CONF_CONTEXT_us_east" => "east-context"}
...> compile_config = %{us_west: %{conf: "compiletime/path/to/us_west.conf"}}
...> K8s.Config.runtime_clusters_config(env, compile_config)
%{us_east: %{conf: "runtime/path/to/us_east.conf", conf_opts: [context: "east-context"]}, us_west: %{conf: "compiletime/path/to/us_west.conf"}}