0

I'm using the python kubernetes client to control deployment of resources. I'd like to poll the status of multiple resources at once to provide near-realtime feedback on when a given set of resources is available. Right now I have to query each resources individually, which seems excessive on a system where each set of resources scales by N users (so if there are 6 resources there would be N(6) requests for a status check).

Is there way to query the API and get the status of all resources that match a given label selector? If not, is there another approach I should consider?

3

get the status of all resources that match a given label selector?

I started out by seeing how kubectl does it, because at high enough verbosity levels, it shows the actual underlying HTTP transactions:

kubectl --v=8 get deploy,pod  -l app.kubernetes.io/name=something

seems to issue two separate GET calls, so I believe it is just putting them in flight concurrently and then awaiting the threads.

As for the other half of your question,

kubectl --v=8 get all -l app.kubernetes.io/name=something

does the same thing as the CSV version, but instead appears to do something akin to kubectl api-resources (or maybe has a hard-coded list of what it considers all?) and then does the same thing: putting multiple GET in flight and awaiting the threads

You may be interested in exploring how kubectl rollout status operates, to see if that might help you. I also tried adding --watch to the get all and was informed:

F0730 21:55:36.819494 2887268 helpers.go:115] error: you may only specify a single resource type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.