【问题标题】:How to pipe log output inside of container in Kubernetes/OpenShift?如何在 Kubernetes/OpenShift 的容器内通过管道传输日志输出?
【发布时间】:2021-03-16 10:29:26
【问题描述】:

我想像node example.js|node_modules/bunyan/bin/bunyan 这样通过管道输出我的nodejs 文件以提高可读性。 如何在 yaml 中指定?

我尝试了几种方法,例如:

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

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

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

但没有一个奏效。
是否有可能,如果可以,正确的方法是什么?

【问题讨论】:

  • 您能详细说明一下吗?您在 kubernetes 中有带有 nodejs 的 pod,并且您想从该应用程序中输出一些日期到文件?您想从 kubernetes 级别读取 if 吗?你能分享一些背景吗?

标签: node.js kubernetes yaml openshift bunyan


【解决方案1】:

试试这个(前提是您的容器有/bin/sh 可用)

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

【讨论】:

    【解决方案2】:

    感谢您的帮助,但我已经找到了适合我的解决方案。 我没有直接使用命令,而是将其存储在 shell 脚本中并用于执行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-26
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 2018-03-07
      • 1970-01-01
      相关资源
      最近更新 更多