Kube Util could not get api url from kubeconfig
Kube Util could not get api url from kubeconfig when cluster name is not match with current-context Current code flow will iterator each cluster in kube config, and then find matched name with current context. The cluster's server could not been found if cluster name is not match with current context. We should find match context name instead cluster name, and then using context's cluster name to find cluster. Finally get the cluster's server Change-Id: Ia8a5004552e47e2216fe6413e0359a0df59a3d4e Closed-Bug: 1669788
This commit is contained in:
parent
f69c274df9
commit
979c5bdabe
|
@ -269,11 +269,13 @@ class KubeUtils(object):
|
|||
return ('', code)
|
||||
|
||||
configuration = YamlUtils.yaml_dict_from_string(res)
|
||||
for context in configuration['contexts']:
|
||||
if context['name'] != current_context:
|
||||
continue
|
||||
|
||||
for cluster in configuration['clusters']:
|
||||
server = cluster['cluster']['server']
|
||||
context = cluster['name']
|
||||
if context == current_context:
|
||||
return server
|
||||
context_cluster = context['context']['cluster']
|
||||
for cluster in configuration['clusters']:
|
||||
if cluster['name'] == context_cluster:
|
||||
return cluster['cluster']['server']
|
||||
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue