{"action":"created","comment":{"url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments/82672145","pull_request_review_id":3563755,"id":82672145,"diff_hunk":"@@ -0,0 +1,184 @@\n+<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->\n+\n+<!-- BEGIN STRIP_FOR_RELEASE -->\n+\n+<img src=\"http://kubernetes.io/kubernetes/img/warning.png\" alt=\"WARNING\"\n+     width=\"25\" height=\"25\">\n+<img src=\"http://kubernetes.io/kubernetes/img/warning.png\" alt=\"WARNING\"\n+     width=\"25\" height=\"25\">\n+<img src=\"http://kubernetes.io/kubernetes/img/warning.png\" alt=\"WARNING\"\n+     width=\"25\" height=\"25\">\n+<img src=\"http://kubernetes.io/kubernetes/img/warning.png\" alt=\"WARNING\"\n+     width=\"25\" height=\"25\">\n+<img src=\"http://kubernetes.io/kubernetes/img/warning.png\" alt=\"WARNING\"\n+     width=\"25\" height=\"25\">\n+\n+<h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2>\n+\n+If you are using a released version of Kubernetes, you should\n+refer to the docs that go with that version.\n+\n+<!-- TAG RELEASE_LINK, added by the munger automatically -->\n+<strong>\n+The latest release of this document can be found\n+[here](http://releases.k8s.io/release-1.4/docs/design/websockets-watches-proposal.md).\n+\n+Documentation for other releases can be found at\n+[releases.k8s.io](http://releases.k8s.io).\n+</strong>\n+--\n+\n+<!-- END STRIP_FOR_RELEASE -->\n+\n+<!-- END MUNGE: UNVERSIONED_WARNING -->\n+\n+# WebSockets Watches Proposal: DRAFT\n+\n+## Abstract\n+\n+This proposal aims to enable kubernetes watch APIs to allow watching more than one resource\n+over a WebSocket connection to a single domain.\n+\n+## Background\n+\n+Kubernetes provides to its clients watch APIs that help them to be notified of any changes to kubernetes\n+resources (such as pods, replication controllers, nodes, services etc.) when they happen. These watch APIs\n+can be accessed over HTTP(S) or WebSocket (secure, non-secure) connections. However, due to the nature\n+(notifications, updates like pushes from a server) of watches, WebSockets are more suitable for them and\n+hence are used more commonly. As an example, Openshift (built on kubernetes) web client uses WebSockets\n+for accessing watch APIs.\n+\n+## Problem Statement\n+\n+Web based clients, like web browsers (IE, Chrome, and most likely others too), limit the number of open\n+WebSocket connections to a single domain to 6 connections. As the current watch APIs only allow watching\n+one resource per connection, this means that WebSocket connections to watch resources are then limited to\n+watching only 6 different resources. Since the inception of kubernetes, its resource types have grown to\n+a large number (for example PetSets/ReplicaSets/Deployments) and are expected to keep growing in the near\n+future too. Due to this growth, the limitation to watching 6 resources at one time is becoming a major\n+concern for web based clients.\n+\n+## Motivation\n+\n+To allow kubernetes' web based clients to be able to watch more than 6 resources simultaneously\n+to a single domain.\n+\n+## Use cases\n+\n+1. A user/admin needing to watch on multiple resources through a single WebSocket connection.\n+2. 1. web based system monitoring where it may be desired to watch more than 6 resources simultaneously\n+to have a more comprehensive view of system health.\n+\n+## Solutions\n+\n+Here we discuss two solutions to address the problem.\n+\n+### A watch request with multiple resources \n+\n+The steps in this solution are:\n+\n+* Clients should be able to specify watch request as follows:\n+\n+```\n+/api/v1/watch/pods,nodes,rc,services\n+/api/v1/watch/pods?resourceVersion=4&timeoutSeconds=319,nodes?resourceVersion=6&timeoutSeconds=280\n+```\n+\n+  A client opens a WebSocket connection to a kube api server and sends the above watch request to the server.\n+\n+* The API server's resthandler in `pkg/apiserver/resthandler.go` identifies it as a watch on multiple resources. \n+The request is routed to WebSocket handler `in pkg/apiserver/watch.go` via `serveWatch()` in `pkg/apiserver/resthandler.go`.\n+\n+* The `serveWatch()` in `pkg/apiserver/resthandler.go` parses the request and creates a WebSocket\n+server to handles multiple watches. \n+\n+* The WebSocket server in `pkg/apiserver/watch.go` creates a slice of watches for resources.\n+\n+```\n+type WatchServer struct {\n+watching []watch.Interface\n+.\n+.\n+}\n+```\n+\n+* The WebSocket handler HandleWS in `pkg/apiserver/watch.go` handles all watches.\n+\n+#### Validation\n+\n+The resthandler validates that requested resources are indeed one of the existing kube resources.\n+\n+#### Limiting number of resources per request\n+\n+This solution also requires limiting number of resources to watch per request, as allowing\n+number of resources without upper bound would lead to an increased amount of response data that\n+might overwhelm the connection.\n+\n+```\n+type WatchServer struct {\n+watching []watch.Interface\n+.\n+.\n+maxAllowedRequest int32\n+}\n+```\n+\n+Where `maxAllowedRequest` could be something `5` or `10` (or something else).\n+\n+### Multiple watch requests at different times over a WebSocket Connection\n+\n+In this solution, the expected steps are:\n+\n+1. A client opens a WebSocket connection to a Kubernetes API server.\n+\n+2. The client then sends a watch request for a particular resource over the connection.\n+\n+3. The api server responds to the request.\n+\n+4. The client then may open another watch request on the same connection for a different resource\n+while the previous watch is still open over the same connection.\n+\n+5. The api server responds to the another watch request over the same connection.\n+\n+6. The steps 4 and 5 are repeated as needed.\n+\n+7. The server may close the connection if all watches are finished for whatever reason or\n+the client closes the connection.\n+\n+This solution is different from the previous one because watch requests are not sent\n+in bulk in the begining as in the previous solution.\n+\n+#### Implementation details\n+\n+To-Do\n+\n+## Open Issues\n+\n+### Impact of more watches on etcd\n+\n+In kubernetes, when a client sends a watch request to kubernetes apiserver, the apiserver opens an watch on etcd","path":"docs/design/websockets-watches-proposal.md","position":159,"original_position":159,"commit_id":"1d6680e70f43d91e134c08734b2942e2fbe0546e","original_commit_id":"1d6680e70f43d91e134c08734b2942e2fbe0546e","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"body":"oh thanks. I did not know that the etcd watch proposal is already implemented. ","created_at":"2016-10-10T19:58:29Z","updated_at":"2016-10-10T19:58:29Z","html_url":"https://github.com/aveshagarwal/kubernetes/pull/7#discussion_r82672145","pull_request_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments/82672145"},"html":{"href":"https://github.com/aveshagarwal/kubernetes/pull/7#discussion_r82672145"},"pull_request":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7","id":88014733,"html_url":"https://github.com/aveshagarwal/kubernetes/pull/7","diff_url":"https://github.com/aveshagarwal/kubernetes/pull/7.diff","patch_url":"https://github.com/aveshagarwal/kubernetes/pull/7.patch","issue_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/7","number":7,"state":"open","locked":false,"title":"WebSockets watches proposal","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-05T04:29:43Z","updated_at":"2016-10-10T19:58:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13e46d467fbc2f8f89ffc8e85bd0096f1063025d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7/commits","review_comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7/comments","review_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/7/comments","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/1d6680e70f43d91e134c08734b2942e2fbe0546e","head":{"label":"aveshagarwal:master-websockets-watches-proposal","ref":"master-websockets-watches-proposal","sha":"1d6680e70f43d91e134c08734b2942e2fbe0546e","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"repo":{"id":32509925,"name":"kubernetes","full_name":"aveshagarwal/kubernetes","owner":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aveshagarwal/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/aveshagarwal/kubernetes","forks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/forks","keys_url":"https://api.github.com/repos/aveshagarwal/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aveshagarwal/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aveshagarwal/kubernetes/teams","hooks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/events","assignees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/aveshagarwal/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/tags","blobs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/aveshagarwal/kubernetes/languages","stargazers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscription","commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/aveshagarwal/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aveshagarwal/kubernetes/merges","archive_url":"https://api.github.com/repos/aveshagarwal/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aveshagarwal/kubernetes/downloads","issues_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/aveshagarwal/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/aveshagarwal/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aveshagarwal/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/aveshagarwal/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/deployments","created_at":"2015-03-19T08:38:39Z","updated_at":"2016-01-13T15:56:58Z","pushed_at":"2016-10-10T18:24:10Z","git_url":"git://github.com/aveshagarwal/kubernetes.git","ssh_url":"git@github.com:aveshagarwal/kubernetes.git","clone_url":"https://github.com/aveshagarwal/kubernetes.git","svn_url":"https://github.com/aveshagarwal/kubernetes","homepage":"http://kubernetes.io","size":333286,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"aveshagarwal:master","ref":"master","sha":"a6f37d557c789aaae5dd40e023166d3c42c94814","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"repo":{"id":32509925,"name":"kubernetes","full_name":"aveshagarwal/kubernetes","owner":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aveshagarwal/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/aveshagarwal/kubernetes","forks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/forks","keys_url":"https://api.github.com/repos/aveshagarwal/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aveshagarwal/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aveshagarwal/kubernetes/teams","hooks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/events","assignees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/aveshagarwal/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/tags","blobs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/aveshagarwal/kubernetes/languages","stargazers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscription","commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/aveshagarwal/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aveshagarwal/kubernetes/merges","archive_url":"https://api.github.com/repos/aveshagarwal/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aveshagarwal/kubernetes/downloads","issues_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/aveshagarwal/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/aveshagarwal/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aveshagarwal/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/aveshagarwal/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/deployments","created_at":"2015-03-19T08:38:39Z","updated_at":"2016-01-13T15:56:58Z","pushed_at":"2016-10-10T18:24:10Z","git_url":"git://github.com/aveshagarwal/kubernetes.git","ssh_url":"git@github.com:aveshagarwal/kubernetes.git","clone_url":"https://github.com/aveshagarwal/kubernetes.git","svn_url":"https://github.com/aveshagarwal/kubernetes","homepage":"http://kubernetes.io","size":333286,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7"},"html":{"href":"https://github.com/aveshagarwal/kubernetes/pull/7"},"issue":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/7"},"comments":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/1d6680e70f43d91e134c08734b2942e2fbe0546e"}}}}
{"actor":{"display_login":"aveshagarwal"}}