如何将 notes.txt 输出发送到文件而不是将其转储到控制台?

How to send notes.txt output to a file instead of dumping it to the console?

我希望 Helm 将 notes.txt 的输出写入本地文件,而不是将其转储到控制台。我想编写一个 JSON 文件,供另一个系统读取(即发送 Slack 消息)。

如果这不可能,是否有一个单独的 Helm 命令只输出 notes.txt 而无需进行完整部署?

我不想尝试从整个部署输出中捕获和解析它。

helm status <release> 将显示发布状态。这也包含 notes.txt 输出。

Helm 提供了指定 helm status <release-name> 命令 (doc) 的输出格式的能力。所以 运行:

$> helm status <release> -o json

您将以 json 格式获得有关已部署版本的详细信息:

{
  "name": "release",
  "info": {
    "first_deployed": "..",
    "last_deployed": "..",
    "deleted": "",
    "description": "Install complete",
    "status": "deployed",
    "notes": "THIS IS THE FIELD YOU WANT"
  },
  "manifest": "...",
  "version": 1,
  "namespace": "..."
}

根据您使用的 shell,您可以直接将输出保存在文件中(下面的 bash):

$> helm status <release> -o json > out.json

或使用其他机制在保存前进一步处理 json 文件(如 jq):

$> helm status <release> -o json | jq -r '.info.notes'
...
[ only the notes part of the release ]
...