run kubectl from nodejs child_proccess

1/22/2020

I'm trying to run kubectl commands from NodeJs child_proccess.exec .
and i'm getting the following error: stderr: error: timed out waiting for the condition

Here is my code

import childp from 'child_process';
import util from 'util';

const exec = util.promisify(childp.exec);

(async () => {
  const { stdout, stderr } = await exec('kubectl port-forward -n qa svc/payment-service 4008');
  console.log('stdout:', stdout);
  console.log('stderr:', stderr);
})();

the error appears after 60 second, (before the error the port-forward works , but nothing in output)

-- Israel kusayev
child-process
javascript
kubernetes
node.js
terminal

0 Answers