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

Using pykube inside the cluster #82

Closed
diegodelemos opened this issue Oct 14, 2016 · 3 comments
Closed

Using pykube inside the cluster #82

diegodelemos opened this issue Oct 14, 2016 · 3 comments
Labels

Comments

@diegodelemos
Copy link

Hello,

Is pykube prepared to be executed inside a pod and make calls to the Kubernetes API? I need to query it to know the state of a Job, and if it has not ended (no successful nor fail) I would like to wait until it happens.

Thanks so much!

@diegodelemos
Copy link
Author

diegodelemos commented Oct 20, 2016

I suppose it is possible since here config.py is prepared to retrieve the credentials from a pod.

@brosner
Copy link
Contributor

brosner commented Oct 21, 2016

To give an official answer, yes, pykube is very capable of making calls within the cluster. The classmethod you link to is exactly the way to do it too.

I can vouch for pykube running in-cluster in production and it works great!

@mdavis-xyz
Copy link

How do you use it within the cluster? I get an error because the api object does not have a config attributes.

MWE:

import pykube                  
api = pykube.KubeConfig.from_service_account()             
pykube.Service.objects(api)

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/pykube/objects.py", line 17, in __call__
    namespace = api.config.namespace
AttributeError: 'KubeConfig' object has no attribute 'config'

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

No branches or pull requests

3 participants