kube-ops-view icon indicating copy to clipboard operation
kube-ops-view copied to clipboard

kubeconfig logic requires 'current-context' even when --kubeconfig-contexts are provided

Open ankon opened this issue 8 years ago • 1 comments

$ python3 -m kube_ops_view --kubeconfig-path ~/kubeconfig --kubeconfig-contexts production
INFO:kube_ops_view.main:Listening on :8080..
ERROR:kube_ops_view.update:Failed to update
Traceback (most recent call last):
  File "/home/pi/kube-ops-view/kube_ops_view/update.py", line 42, in update_clusters
    for cluster in clusters:
  File "/home/pi/kube-ops-view/kube_ops_view/cluster_discovery.py", line 139, in get_clusters
    contexts, current_context = kubernetes.config.list_kube_config_contexts(config_file)
  File "/usr/local/lib/python3.4/dist-packages/kubernetes/config/kube_config.py", line 279, in list_kube_config_contexts
    loader = _get_kube_config_loader_for_yaml_file(config_file)
  File "/usr/local/lib/python3.4/dist-packages/kubernetes/config/kube_config.py", line 271, in _get_kube_config_loader_for_yaml_file
    **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/kubernetes/config/kube_config.py", line 108, in __init__
    self.set_active_context(active_context)
  File "/usr/local/lib/python3.4/dist-packages/kubernetes/config/kube_config.py", line 120, in set_active_context
    context_name = self._config['current-context']
  File "/usr/local/lib/python3.4/dist-packages/kubernetes/config/kube_config.py", line 242, in __getitem__
    % (key, self.name))
kubernetes.config.config_exception.ConfigException: Invalid kube-config file. Expected key current-context in kube-config

I think this is too strict: given that I am providing the name of the context to use, there is really no point in requiring a "current" context.

ankon avatar Mar 17 '17 08:03 ankon

@ankon thanks for reporting, I think this is a bug in the used Kubernetes client library. I wanted to switch away anyway, see #112 (haven't checked yet whether this would fix this issue).

hjacobs avatar Mar 17 '17 10:03 hjacobs