I am trying to execute a command in contianer (in Kubernetes POD on GKE with kubernet 1.1.2).
Reading documentation. I realized that I could use a GET or POST request to open a connection to the websocket on the API endpoint to execute the command. When I use GET, it does not work completely, it returns an error. When I try to use POST, something like this might work (but it doesn't):
curl 'https://admin: xxx@IP /api/v1/namespaces/default/pods/hello-whue1/exec?stdout=1&stderr=1&command=ls' -H "Connection: upgrade" -k -X POST -H 'Upgrade: websocket'
repsponse for this
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"}}
It seems like this should be enough to update the mail request and start using websocket streams, right? What am I missing?
I also pointed out that opening a websocket with POST is probably a violation of the websocket protocol (should only GET work?).
Besides
source share