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

Document how to use this with kubectl proxy #303

Closed
yuvipanda opened this issue Jul 23, 2017 · 7 comments
Closed

Document how to use this with kubectl proxy #303

yuvipanda opened this issue Jul 23, 2017 · 7 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@yuvipanda
Copy link
Contributor

I've been profiling an application that talks heavily to the k8s API. A big performance bottleneck is doing TLS in python. It'd be great if instead I can run a kubectl proxy as a sidecar, and direct requests to there. That way, the go proxy deals with TLS (and is much faster)!

I'm not entirely sure how to construct a Configuration object that'll work for this tho. kubectl proxy by default provides an unauthenticated http port..

@mbohlool
Copy link
Contributor

This should work:

from kubernetes.client import configuration
configuration.host = "127.0.0.1:8001"

# no need to call config.load_kube_config()

If you want a client with this config but don't want to change global config:

from kubernetes import client
from kubernetes.client import Configuration, ApiClient
myconfig=Configuration()
myconfig.host = "127.0.0.1:8001"
myapiclient = ApiClient(config=myconfig)
v1 = client.CoreV1Api(api_client=myapiclient)

# no need to call config.load_kube_config()

Note: 127.0.0.1:8001 is what kubectl proxy normally listen to proxy calls to main cluster. The port however can change based on availability. use what kubectl proxy reports.

@yuvipanda
Copy link
Contributor Author

Thank you, this is useful. Is the singleton Configuration object still recommended or should I switch to using this instead in all my code?

@mbohlool
Copy link
Contributor

It is completely depends on your application. Singleton is for ease of use when you only talk to one cluster. If you want to connect to multiple clusters concurrently then you need to follow the second example.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 21, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 21, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants