Use kubeconfig if either context or kubeconfig is set (#47373) (#47496)

* Use kubeconfig if either context or kubeconfig is set (#47373)

kubeconfig should be loaded if *either* or both of context
or kubeconfig is set (this allows picking a context and default
kubeconfig or picking a kubeconfig with default context)

Fixes #47149

(cherry picked from commit 00ccad9764)

* Add changelog for k8s auth config fix
This commit is contained in:
Will Thames 2018-10-25 00:33:20 +10:00 committed by Toshio Kuratomi
parent 136da25bbf
commit 1c9551f93d
2 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- k8s - allow kubeconfig or context to be set without the other

View file

@ -152,7 +152,7 @@ class K8sAnsibleMixin(object):
if auth_set('username', 'password', 'host') or auth_set('api_key', 'host'):
# We have enough in the parameters to authenticate, no need to load incluster or kubeconfig
pass
elif auth_set('kubeconfig', 'context'):
elif auth_set('kubeconfig') or auth_set('context'):
kubernetes.config.load_kube_config(auth.get('kubeconfig'), auth.get('context'))
else:
# First try to do incluster config, then kubeconfig