Kubernetes Websockets API pod exec node.js client send method Kubernetes Websockets API pod exec node.js client send method kubernetes kubernetes

Kubernetes Websockets API pod exec node.js client send method


I know that my answer comes late. But maybe I can help someone else with this. I have noticed that often the Kubernetes API requires to set an origin when using websockets. Otherwise the API returns strange errors sometimes. In your case you could try to complete your options as follows:

const options = {  headers: {    'Authorization': `Bearer ${access_token}`  },  ca: fs.readFileSync('ca.crt'),  origin: 'https://<the_api_url>:<port>'}

Furthermore I think that it is not required to set wss as protocol (in your host_address variable). Usually the protocol should be automatically upgraded from https to wss during the connection process.