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

Support for multiple config files #146

Open
varac opened this issue Mar 20, 2019 · 2 comments
Open

Support for multiple config files #146

varac opened this issue Mar 20, 2019 · 2 comments
Assignees

Comments

@varac
Copy link

varac commented Mar 20, 2019

I need to deal with multiple clusters. Instead of merging all cluster configs into one file I maintain them in seperate config files, and export my KUBECOFIG env variable like this:

 ~ $ env | grep KUBE
KUBECONFIG=/home/varac/.kube/[email protected]:/home/varac/.kube/[email protected]

This is one official way of organizing your cluster configs with kubectl and works with kubectl really fine for me, i.e.

 ~ $ kubectl config get-clusters
NAME
cluster1
cluster2

However, kubernets-py fails to deal with multiple config files referenced in KUBECONFIG env var:

In [1]: from kubernetes_py import K8sConfig

In [2]: cfg_default = K8sConfig()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-2-4b42c288a7cf> in <module>()
----> 1 cfg_default = K8sConfig()

/home/varac/.local/lib/python3.6/site-packages/kubernetes_py/K8sConfig.py in __init__(self, kubeconfig, api_host, auth, cert, namespace, pull_secret, token, version)
     63         self.version = None
     64 
---> 65         self._init_with_defaults()
     66 
     67         if kubeconfig is None:

/home/varac/.local/lib/python3.6/site-packages/kubernetes_py/K8sConfig.py in _init_with_defaults(self)
    138         kubeconfig = os.getenv(KUBECONFIG_ENV_VAR, None)
    139         if kubeconfig is not None:
--> 140             self._read_config(filename=kubeconfig)
    141             return
    142 

/home/varac/.local/lib/python3.6/site-packages/kubernetes_py/K8sConfig.py in _read_config(self, filename)
    171 
    172         if not isfile(filename):
--> 173             raise IOError('K8sConfig: kubeconfig: [ {0} ] doesn\'t exist.'.format(filename))
    174         try:
    175             with open(filename, 'r') as stream:

OSError: K8sConfig: kubeconfig: [ 
/home/varac/.kube/[email protected]:/home/varac/.kube/[email protected] ] doesn't exist.
@sebastienc sebastienc self-assigned this Mar 20, 2019
@sebastienc
Copy link
Contributor

I'll have a look at it. It could be pretty useful to support this.

@varac
Copy link
Author

varac commented Mar 21, 2019

See kubernetes-client/python#723 for the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants