Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve configuration loading and add ability to merge configurations #69

Merged
merged 5 commits into from
Dec 29, 2018

Conversation

kke
Copy link
Contributor

@kke kke commented Dec 13, 2018

Fixes #68
Would help solve kontena/mortar#86

  • Adds K8s::Client.autoconfig which attempts to build or load a configuration using the information available from the environment or local filesystem , see below
  • Enable namespace: parameter in K8s::Client.in_cluster_config
  • Make all attributes of K8s::Config optional and initialize empty objects as default values
  • Add K8s::Config.merge that follows the rules specified in kube docs
  • Add K8s::Config.from_kubeconfig_env that parses config file paths from KUBECONFIG and merges the configurations together if it specifies multiple paths (separated by : as documented in kube docs)
  • Add K8s::Config.build that can be used to build a minimal working configuration by passing in at least kubernetes server address, certificate authority data and an access token.
  • Improves yardocs for some methods

Autoconfig look-up order:

  • KUBE_TOKEN, KUBE_CA, KUBE_SERVER environment variables (Using K8s::Config.build)
  • KUBECONFIG environment variable (Using K8s::Config.from_kubeconfig_env)
  • $HOME/.kube/config file (Using K8s::Config.load_file)
  • In cluster configuration (when running inside a kube cluster) (Using K8s::Transport.in_cluster_config)

Breaking changes:

  • in_cluster_config now raises if the environment variables are not set (it would have raised anyway if the hardcoded paths were not readable)
  • K8s::Config.new does not raise when initialized without previously required parameters (does not break if it was used in a way that worked previously)

@kke kke added the enhancement New feature or request label Dec 13, 2018
@kke kke requested a review from jnummelin December 13, 2018 14:27
Copy link
Contributor

@jakolehm jakolehm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jakolehm
Copy link
Contributor

@jnummelin PTAL

@jnummelin jnummelin merged commit 3dc9565 into master Dec 29, 2018
@jnummelin jnummelin deleted the feature/improve_configuration branch December 29, 2018 06:50
@jakolehm jakolehm mentioned this pull request Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants