k8s v0.5.0-rc.2 K8s.Conn.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.
Cluster configuration read from env variables.
To be merged over Application.get_env(:k8s, :clusters)
.
Parses ENV variables to runtime cluster configs
Link to this section Functions
Returns runtime and compile time cluster configuration merged together.
Cluster configuration read from env variables.
To be merged over Application.get_env(:k8s, :clusters)
.
Examples
Only specifying compiletime configs
iex> config = %{dev: %{conn: "runtime/path/to/dev.kubeconfig.yaml"}}
...> K8s.Conn.Config.merge_configs(%{}, config)
%{dev: %{conn: "runtime/path/to/dev.kubeconfig.yaml"}}
Only specifying runtime configs
iex> env = %{"K8S_CLUSTER_CONF_PATH_dev" => "runtime/path/to/dev.kubeconfig.yaml"}
...> K8s.Conn.Config.merge_configs(env, %{})
%{dev: %{conn: "runtime/path/to/dev.kubeconfig.yaml"}}
Overriding compile time configs
iex> env = %{"K8S_CLUSTER_CONF_PATH_dev" => "runtime/path/to/dev.kubeconfig.yaml"}
...> compile_config = %{dev: %{conn: "compiletime/path/to/dev.kubeconfig.yaml"}}
...> K8s.Conn.Config.merge_configs(env, compile_config)
%{dev: %{conn: "runtime/path/to/dev.kubeconfig.yaml"}}
Merging compile time configs
iex> env = %{"K8S_CLUSTER_CONF_CONTEXT_dev" => "runtime-context"}
...> compile_config = %{dev: %{conn: "compiletime/path/to/dev.kubeconfig.yaml"}}
...> K8s.Conn.Config.merge_configs(env, compile_config)
%{dev: %{conn: "compiletime/path/to/dev.kubeconfig.yaml", conn_opts: [context: "runtime-context"]}}
Adding clusters at runtime
iex> env = %{"K8S_CLUSTER_CONF_PATH_us_east" => "runtime/path/to/us_east.kubeconfig.yaml", "K8S_CLUSTER_CONF_CONTEXT_us_east" => "east-context"}
...> compile_config = %{us_west: %{conn: "compiletime/path/to/us_west.kubeconfig.yaml"}}
...> K8s.Conn.Config.merge_configs(env, compile_config)
%{us_east: %{conn: "runtime/path/to/us_east.kubeconfig.yaml", conn_opts: [context: "east-context"]}, us_west: %{conn: "compiletime/path/to/us_west.kubeconfig.yaml"}}
Parses ENV variables to runtime cluster configs