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

Match kubectl behavior in commands that use kubeconfig #79

Merged
merged 4 commits into from
May 19, 2021

Conversation

hasheddan
Copy link
Contributor

Updates --kubeconfig flags to not explicitly use environment variables and instead fall back on default kubeconfig loader chain used by kubectl. This means that up is only overriding behavior if an explicit existing path is passed to --kubeconfig.

Fixes #77

Tested this out by creating two different kind clusters and running the following scenarios after exporting kubeconfigs to first.yaml and second.yaml:

  • Add list of paths to KUBECONFIG that includes first.yaml but not second.yaml -- first cluster is used
  • Add list of paths to KUBECONFIG that includes second.yaml but not first.yaml -- second cluster is used
  • Add list of paths to KUBECONFIG that includes first.yaml before second.yaml -- first cluster is used
  • Unset KUBECONFIG and current context in ~/.kube/kubeconfig is used
  • Explicitly provide filepath via --kubeconfig and the specified file is used

The kubeconfig builder will automatically use KUBECONFIG env var if
present, so we do not need to replicated the behavior in commands we
support.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
The kubeconfig getter now loads default chains for loading kubeconfig
from environment variables and default path if an explicit path is not
set.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Revises the kubeconfig flag description to more accurately
describe its behavior.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Updated docstring for kubeconfig getter to appropriately represent
behavior.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better Compatibility on KUBECONFIG with other Kubernetes Clients
2 participants