How to execute command in a pod (kubernetes) using API?

6,138 views
Skip to first unread message

Robinly

unread,
Feb 28, 2017, 4:30:09 AM2/28/17
to Kubernetes user discussion and Q&A
I want to execute command in a container using k8s API, don't use any libraries or tools.

Example:
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "Upgrade request required",
  "reason": "BadRequest",
  "code": 400
}

there is a error. 

The /api/v1/proxy should I use? what should I do?

Madhukar Nayakbomman

unread,
Jul 28, 2017, 7:53:59 PM7/28/17
to Kubernetes user discussion and Q&A
Hi Robinly,

How did you work through this issue? Is there any API which we can use for executing a command in a container?

Thanks,
Madhukar

Rodrigo Campos

unread,
Jul 28, 2017, 11:32:00 PM7/28/17
to kubernet...@googlegroups.com
If it wasn't resolved as it's not in the documentation wiki (sorry, away from laptop now) you can probably check how kubectl exec does it. It might not be the simpler code, but it may shed some light
--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Matthias Rampke

unread,
Jul 29, 2017, 7:50:14 AM7/29/17
to kubernet...@googlegroups.com

I haven't tried this, but IIRC the required upgrade is to HTTP/2. Try `curl --http2`?

/MR


On Sat, Jul 29, 2017, 05:31 Rodrigo Campos <rodr...@gmail.com> wrote:
If it wasn't resolved as it's not in the documentation wiki (sorry, away from laptop now) you can probably check how kubectl exec does it. It might not be the simpler code, but it may shed some light

On Friday, July 28, 2017, Madhukar Nayakbomman <madhuka...@gmail.com> wrote:
Hi Robinly,

How did you work through this issue? Is there any API which we can use for executing a command in a container?

Thanks,
Madhukar

On Tuesday, February 28, 2017 at 1:30:09 AM UTC-8, Robinly wrote:
I want to execute command in a container using k8s API, don't use any libraries or tools.

Example:
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "Upgrade request required",
  "reason": "BadRequest",
  "code": 400
}

there is a error. 

The /api/v1/proxy should I use? what should I do?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

Eric Tune

unread,
Jul 31, 2017, 11:16:09 AM7/31/17
to Kubernetes user discussion and Q&A
Did you know if you run kubectl with -v=10 it prints the equivalent curl command for the command you just ran?
Try "kubectl exec -v=10 $PODNAME -- ls"
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

Mehdy Bohlool

unread,
Aug 8, 2017, 6:56:33 AM8/8/17
to Kubernetes user discussion and Q&A
This is a little old, but you can also take a look at our client python, specifically this example: https://github.com/kubernetes-incubator/client-python/blob/master/examples/exec.py


On Tuesday, February 28, 2017 at 1:30:09 AM UTC-8, Robinly wrote:

yl...@linkernetworks.co

unread,
Mar 10, 2018, 6:31:14 AM3/10/18
to Kubernetes user discussion and Q&A
I think the API requires the client to upgrade the connection to WebSocket

ling li

unread,
Jun 29, 2018, 5:25:12 AM6/29/18
to Kubernetes user discussion and Q&A
hi, any solution for this issue?
I test with postman.
And I got the same error even I have tried with serval para and headers

在 2017年7月31日星期一 UTC+8下午11:16:09,Eric Tune写道:
Reply all
Reply to author
Forward
0 new messages