python icon indicating copy to clipboard operation
python copied to clipboard

stream(api_instance.connect_post_namespaced_pod_attach, ...) doesn't perform a POST

Open DamianFekete opened this issue 1 year ago • 4 comments

Link to the issue (please include a link to the specific documentation or example): https://github.com/kubernetes-client/python/blob/master/examples/pod_exec.py

Description of the issue (please include outputs or screenshots if possible): I think it would be helpful if the documentation, or at least the reference code example mentioned above, would make it clear that stream(api_instance.connect_post_namespaced_pod_attach, ...) behaves differently from kubectl exec, and requires a different K8s Role configuration:

  • kubectl uses SPDY and makes a POST request
  • stream(api_instance.connect_post_namespaced_pod_attach, ...) uses websockets and stream(...) converts the POST request to a GET request.

The permission for pods/exec has to include the verb create for kubectl, and get for the Python code mentioned above.

This could save some time when debugging why the library doesn't work.

  • The Python api call without the verb get permitted:

pods "toolbox" is forbidden: User "system:serviceaccount:serviceaccounts:username" cannot get resource "pods/exec" in API group "" in the namespace "playground"

The word get is used instead of create (because the request was not a POST HTTP request).

  • kubectl:
$ kubectl -n playground exec toolbox --v=8 echo test
...
I0704 16:24:58.079971   14688 round_trippers.go:463] POST https://1.2.3.4:1234/api/v1/namespaces/playground/pods/toolbox/exec?command=echo&command=test&container=toolbox&stderr=true&stdout=true
...
I0704 16:24:58.286950   14688 round_trippers.go:574] Response Status: 101 Switching Protocols in 206 milliseconds
I0704 16:24:58.287542   14688 round_trippers.go:577] Response Headers:
I0704 16:24:58.288704   14688 round_trippers.go:580]     Connection: Upgrade
I0704 16:24:58.288792   14688 round_trippers.go:580]     Upgrade: SPDY/3.1

DamianFekete avatar Jul 04 '23 15:07 DamianFekete

cc @yliaog

roycaihw avatar Jul 31 '23 16:07 roycaihw

@DamianFekete could you help send a pr for the documentation you suggested?

yliaog avatar Jul 31 '23 19:07 yliaog

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 25 '24 12:01 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Feb 24 '24 13:02 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Mar 25 '24 14:03 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 25 '24 14:03 k8s-ci-robot