How to pipe log output inside of container in Kubernetes/OpenShift?

410 views Asked by At

I have want to pipe the output of my nodejs file like node example.js|node_modules/bunyan/bin/bunyan for better readability. How can I specify this in the yaml?

I tried several things like:

      command:
        - node
      args:
        - index.js | node_modules/bunyan/bin/bunyan

or

command:
        - node
      args:
        - index.js 
        - node_modules/bunyan/bin/bunyan

or

command:
        - node index.js | node_modules/bunyan/bin/bunyan

but none of it worked.
Is it possible and if yes, whats the correct way to do it?

2

There are 2 answers

0
Calipee On BEST ANSWER

Thanks for your help but I already found a solution that worked for me. Instead of directly using the command I stored it in a shell script and use it for execution.

0
Syam Sankar On

Try this (provided your container have /bin/sh available)

command: ["/bin/sh"]
args: ["-c", "node example.js|node_modules/bunyan/bin/bunyan"]