Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Setting current context explicitly still sends requests to the context set in kubeconfig file #97

Open
ecthiender opened this issue Nov 23, 2016 · 1 comment

Comments

@ecthiender
Copy link

ecthiender commented Nov 23, 2016

Expected behaviour: When the current_context is set explictly using KubeConfig.set_current_context, and then further Kubernetes requests are made, Kubernetes requests are being made to new context that is set.

Actual behaviour: When the current_context is set explictly using KubeConfig.set_current_context, and then further Kubernetes requests are made, Kubernetes requests are being made to the context set in "kubeconfig" file.

Steps to reproduce (the current-context in my kube config file is test123):

config = pykube.KubeConfig.from_file("/home/Me/.kube/config")
api = pykube.HTTPClient(config)
config.set_current_context("test42")
pykube.ConfigMap.objects(api).get_by_name("my-config")

Executing the above tries to fetch the configmap from the "test123" context and not from the "test42" context.

@jayme-github
Copy link
Contributor

Can confirm that. Switching context before instantiating HTTPClient works though:

config = pykube.KubeConfig.from_file("/home/Me/.kube/config")
config.set_current_context("test42")
api = pykube.HTTPClient(config)
pykube.ConfigMap.objects(api).get_by_name("my-config")

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

No branches or pull requests

2 participants