kubernetes/client-node: Not able to execute command on specific pod

Viewed 16

I want to execute command which will invoke API from specific pod specified in k8s cluster.

const k8s = require('@kubernetes/client-node')
const stream = require('stream')

const kc = new k8s.KubeConfig()
kc.loadFromDefault()

const k8sApi = kc.makeApiClient(k8s.CoreV1Api)
const exec = new k8s.Exec(kc)

const podName = 'test-pod-66fd96bf66-jd6wf'
const containerName = 'test-container'
const command = 'wget -O /dev/null -q http://localhost:5000/sayHi'

exec.exec('default', podName, containerName, command, null, null, null, false).catch(err => {
  console.log(err)
})

I am getting Unexpected server response: 400 error.

0 Answers
Related