using watch/namespaces/{namespace}/pods

720 views
Skip to first unread message

Priyadarshini Anand

unread,
Apr 13, 2016, 7:44:09 AM4/13/16
to kubernetes-dev
Hi,


I want to use GET /api/v1/watch/namespaces/{namespace}/pods/{name} api to keep watching status(phase) of a given pod till the time pod is running phase unless timeout happens. How to pass time out and  fieldSelector in this api? Please share some example.

Thanks.

Wojciech Tyczynski

unread,
Apr 13, 2016, 8:13:04 AM4/13/16
to Priyadarshini Anand, kubernetes-dev
  Hi,
 This actually should work fine. I'm looking into my apiserver logs and I'm seeing line like this one:

I0413 12:10:23.254442       5 handlers.go:159] GET /api/v1/watch/nodes?fieldSelector=spec.unschedulable%3Dfalse&resourceVersion=38801&timeoutSeconds=465: (7m45.000401773s) 200 [[kube-scheduler/v1.3.0 (linux/amd64) kubernetes/c42855b] 127.0.0.1:45875]

 That said, timeoutSeconds=465 seems to work correctly, as the request finished after exactly 465seconds (which is 7m45s).

 What Kubernetes version are you using?

 Thanks
wojtek

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/df6617c3-cb9d-4826-846b-29d0abba84ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Priyadarshini Anand

unread,
Apr 14, 2016, 1:51:06 AM4/14/16
to kubernetes-dev
I am using 1.1.6 ....your are using nodes to watch but I need to watch pods

Wojciech Tyczynski

unread,
Apr 14, 2016, 2:08:57 AM4/14/16
to Priyadarshini Anand, kubernetes-dev
On Thu, Apr 14, 2016 at 7:51 AM, Priyadarshini Anand <epriy...@gmail.com> wrote:
I am using 1.1.6 ....your are using nodes to watch but I need to watch pods

Sure - but the underlying machinery is exactly the same.

And it seems that support for that wasn't in 1.1.6 release. It was added in the commit:

and it seems the first release it is in is: "v1.2.0-alpha.3"

 So it seems you should try 1.2 release to have this working.

 Thanks
wojtek



On Wednesday, April 13, 2016 at 5:14:09 PM UTC+5:30, Priyadarshini Anand wrote:
Hi,


I want to use GET /api/v1/watch/namespaces/{namespace}/pods/{name} api to keep watching status(phase) of a given pod till the time pod is running phase unless timeout happens. How to pass time out and  fieldSelector in this api? Please share some example.

Thanks.

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.

Priyadarshini Anand

unread,
Apr 14, 2016, 2:55:58 AM4/14/16
to kubernetes-dev, epriy...@gmail.com
Thanks,   we can use 1.2.0 stable version - not sure if  "v1.2.0-alpha.3" is part of 1.2.0 stable version

Wojciech Tyczynski

unread,
Apr 14, 2016, 3:03:29 AM4/14/16
to Priyadarshini Anand, kubernetes-dev
 Yes - it will be in all stable 1.2.* releases. I think it's better to use the newest 1.2.* release, which is 1.2.2 now.

Priyadarshini

unread,
Apr 14, 2016, 6:37:30 AM4/14/16
to Wojciech Tyczynski, kubernetes-dev
Thanks, I can see timeout working in 1.2*. Now, I want to watch endpoint and see if all addresses are included.
Like, when I created service and replication controller with replica=10. I want to wait till all 10 replicas ip addresses are in output of call (or timeout happens) -


format in ip addresses in output:
"subsets":[{"addresses":[{"ip":"172.17.100.2",....

Is it required to add ?resourceVersion= in watch get call, when I add I get error - too old resource version: 929 (6169)

?watch=true&timeoutSeconds=50 :: what this mean? Keep watching at least till 50 seconds and then return output?

Wojciech Tyczynski

unread,
Apr 14, 2016, 6:57:26 AM4/14/16
to Priyadarshini, kubernetes-dev
On Thu, Apr 14, 2016 at 12:37 PM, Priyadarshini <epriy...@gmail.com> wrote:
Thanks, I can see timeout working in 1.2*. Now, I want to watch endpoint and see if all addresses are included.
Like, when I created service and replication controller with replica=10. I want to wait till all 10 replicas ip addresses are in output of call (or timeout happens) -


format in ip addresses in output:
"subsets":[{"addresses":[{"ip":"172.17.100.2",....

Is it required to add ?resourceVersion= in watch get call, when I add I get error - too old resource version: 929 (6169)

resourceVersion is not required, but if you don't specify it, you have no guarantee at what point the watch starts
 

?watch=true&timeoutSeconds=50 :: what this mean? Keep watching at least till 50 seconds and then return output?

?watch=true - I think this one is unnecessary, since you already have "/watch/" in the adress
timeoutSeconds=50 means that watch will break after 50seconds

Priyadarshini

unread,
Apr 14, 2016, 7:00:23 AM4/14/16
to Wojciech Tyczynski, kubernetes-dev

So, I run watch API and see if 10 address added in output, if not again run watch n number of times where n is specified

Wojciech Tyczynski

unread,
Apr 14, 2016, 7:01:38 AM4/14/16
to Priyadarshini, kubernetes-dev
On Thu, Apr 14, 2016 at 1:00 PM, Priyadarshini <epriy...@gmail.com> wrote:

So, I run watch API and see if 10 address added in output, if not again run watch n number of times where n is specified


Sorry - I don't understand what you mean. Can you clarify?

Brian Grant

unread,
Apr 14, 2016, 3:52:31 PM4/14/16
to kubernetes-dev, epriy...@gmail.com


On Thursday, April 14, 2016 at 3:57:26 AM UTC-7, Wojciech Tyczynski wrote:

On Thu, Apr 14, 2016 at 12:37 PM, Priyadarshini wrote:
Thanks, I can see timeout working in 1.2*. Now, I want to watch endpoint and see if all addresses are included.
Like, when I created service and replication controller with replica=10. I want to wait till all 10 replicas ip addresses are in output of call (or timeout happens) -


format in ip addresses in output:
"subsets":[{"addresses":[{"ip":"172.17.100.2",....

Is it required to add ?resourceVersion= in watch get call, when I add I get error - too old resource version: 929 (6169)

resourceVersion is not required, but if you don't specify it, you have no guarantee at what point the watch starts
 

?watch=true&timeoutSeconds=50 :: what this mean? Keep watching at least till 50 seconds and then return output?

?watch=true - I think this one is unnecessary, since you already have "/watch/" in the adress
timeoutSeconds=50 means that watch will break after 50seconds

/watch in the path is deprecated. Please use ?watch=true.
 
 



On Thu, Apr 14, 2016 at 12:33 PM, Wojciech Tyczynski wrote:
 Yes - it will be in all stable 1.2.* releases. I think it's better to use the newest 1.2.* release, which is 1.2.2 now.

Priyadarshini

unread,
Apr 15, 2016, 2:44:51 AM4/15/16
to Brian Grant, kubernetes-dev
There is still bug:

http://<ip>/api/v1/namespaces/default/endpoints/svc_name?watch=true&timeoutSeconds=10 --- not working - give output of as if watch not working

Also, fieldSelector not working.

http://<ip>/api/v1/watch/namespaces/default/endpoints/svc_name?timeoutSeconds=10 is working

Wojciech Tyczynski

unread,
Apr 15, 2016, 2:55:52 AM4/15/16
to Priyadarshini, Brian Grant, kubernetes-dev
On Fri, Apr 15, 2016 at 8:44 AM, Priyadarshini <epriy...@gmail.com> wrote:
There is still bug:

http://<ip>/api/v1/namespaces/default/endpoints/svc_name?watch=true&timeoutSeconds=10 --- not working - give output of as if watch not working


You can't pass "service name" as a name to "/endpoints" - it needs to be "endpoint name". Or don't pass the name at all and just pass a fieldSelector.
--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.

Daniel Smith

unread,
Apr 15, 2016, 1:23:16 PM4/15/16
to Wojciech Tyczynski, Priyadarshini, Brian Grant, kubernetes-dev
/watch/ in the path is deprecated and will be removed, as Brian said.

Endpoints should be named the same as their corresponding service.

To watch a single object, I recommend using the collection + name field selector; this lets you use the list/watch pattern, where the list gets you a resource version which you can pass to watch.

I haven't tried it, but I would expect this to work: http://<ip>/api/v1/namespaces/default/endpoints/?watch=true&fieldSelector=metadata.name%3Dsvc_name&timeoutSeconds=10

Note that field selectors other than name are not implemented efficiently at the moment--watch your kube-apiserver resource usage if you do this a lot.




Priyadarshini Anand

unread,
Apr 21, 2016, 4:11:45 AM4/21/16
to kubernetes-dev, woj...@google.com, epriy...@gmail.com, brian...@google.com
Thanks. It is working as suggested.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages