Issue with exec in container using Rancher API

I need to run some commands in a container through Jenkins.
I tried using the kubectl CLI, but it keeps timing out.

I am now trying to use the Rancher API. I’ve tried multiple options but cannot execute my command.
This is the first command I’ve been trying:
curl -X POST "https://myrancher/k8s/clusters/clusterID/api/v1/namespaces/namespacename/pods/podID/exec?container=containername&stdout=true&stdin=true&stderr=true&tty=true" -H "command=powershell some commands" -H "Connection:upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits" -H "Sec-WebSocket-Key: $WebSocketKey" -H "Sec-WebSocket-Protocol: base64.channel.k8s.io" -H "Sec-WebSocket-Version: 13" -H "Accept-Encoding:gzip, deflate, br" -H "Authorization:Bearer $Rancher_Token"

I am getting a weird response:
3SW50ZXJuYWwgZXJyb3Igb2NjdXJyZWQ6IGVycm9yIGV4ZWN1

Any idea what might be happening?

This is a kubernetes api which has nothing specifically to do with Rancher… the first character is the kind of message, and the rest is base64 encoded. That says “Internal error occurred: error execu”.

1 Like

Is there a Rancher API I can use to execute something in a container?
I did try ‘myurl ?action=execute’ but I’m getting Invalid action: execute

I am also trying the rancher cli
rancher exec but I’m getting No help topic for ‘exec’