【问题标题】:How to access volume mount with python script?如何使用 python 脚本访问卷挂载?
【发布时间】:2020-02-17 20:33:29
【问题描述】:

我一直在尝试使用这些方法来访问卷安装中的文件:

with open('./log/file.json', 'w+') as f:
    f.write(json.dumps(output, sort_keys=True, indent=4))

但它不起作用。有什么想法吗?在我的部署文件中,我有这个:

volumeMounts:
- mountPath: /logs
  name: wag-log

【问题讨论】:

    标签: python kubernetes yaml


    【解决方案1】:

    您已经定义了一个volumeMount 并将mountPath 设置为/logs,这会将一个卷安装到/logs 目录中。在您的 Python 代码中,您编写的路径是 ./log/file.json,它不在 /logs 中。

    尝试将日志写入你挂载的目录,例如:

    with open('/logs/file.json', 'w+') as f:
        f.write(json.dumps(output, sort_keys=True, indent=4))
    

    【讨论】:

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