<p>I'm trying to execute command in a contianer (in a Kubernetes POD on GKE with kubernetes 1.1.2). </p>

<p>Reading documentation I understood that I can use GET or POST query to open websocket connection on API endpoint to execute command. When I use GET, it does not work completly, returns error. When I try to use POST, something like that could work probably (but it's not):</p>

<pre><code>curl 'https://admin:xxx@IP/api/v1/namespaces/default/pods/hello-whue1/exec?stdout=1&amp;stderr=1&amp;command=ls' -H "Connection: upgrade" -k -X POST -H 'Upgrade: websocket'
</code></pre>

<p>repsponse for that is</p>

<pre><code>unable to upgrade: missing upgrade headers in request: http.Header{"User-Agent":[]string{"curl/7.44.0"}, "Content-Length":[]string{"0"}, "Accept":[]string{"*/*"}, "Authorization":[]string{"Basic xxx=="}, "Connection":[]string{"upgrade"}, "Upgrade":[]string{"websocket"}}
</code></pre>

<p>Looks like that should be enough to upgrade post request and start using websocket streams, right? What I'm missing?</p>

<p>I was also pointed that opening websocket with POST is probably violation of websocket protocol (only GET should work?).</p>

<p>Also</p>

<p>You'll probably have the best time using the <a href="https://github.com/kubernetes/kubernetes/tree/release-1.1/pkg/client/unversioned" rel="nofollow">Kubernetes client library</a>, which is the same code the Kubectl uses, but if for some reason that isn't an option, than my best suggestion is to look through <a href="https://github.com/kubernetes/kubernetes/blob/release-1.1/pkg/client/unversioned/remotecommand/remotecommand.go" rel="nofollow">the client library's code for executing remote commands</a> and seeing what headers it sets.</p>
