godaddy / godaddy/kubernetes-client

`pod-exec` Fails with 403

Open
#346 9 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
963
Forks
189
PR merge metrics
No merged PRs in 30d

Description

When using the following command:
`api.v1.namespaces('kube-system').pods(albPod.name).exec.get({ qs: { command: ['nginx', '-t'], container: 'nginx-ingress', stdout: true, stderr: true } });`
I get the following error:
```
{ Error: Unexpected server response: 403
at ClientRequest.req.on (node_modules/ws/lib/websocket.js:535:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:544:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:117:17)
at TLSSocket.socketOnData (_http_client.js:440:20)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11) messages: [] }
```
This is the same failure for both `get` and `post`. I have tested using `config.fromKubeconfig(process.env.KUBECONFIG)` but have yet to try using `config.getInCluster()` but I do not think this is an auth issue. I am able to successfully use `kubectl` to get the `nginx -t` output like so:
`kubectl exec -in kube-system albPod.name -c nginx-ingress -- bash -c 'nginx -t'`

My only guess is something to do with the websocket upgrade. I noticed the upgrade response that `kubectl` uses is the following:
```
Response Headers:
Connection: Upgrade
Upgrade: SPDY/3.1
X-Stream-Protocol-Version: v4.channel.k8s.io
```
while the code included here uses for `pod-exec` is using `base64.channel.k8s.io`.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the pod-exec WebSocket upgrade used by the supplied get and post calls with the SPDY/3.1 and channel headers reported by kubectl. Reproduce the 403 with the shown command and verify the change against kubectl's successful nginx -t output; done means both client methods no longer fail with 403.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, kubernetes, nodejs
Domain
api, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.