如何在 Argo 中查看任务日志?

How do I view the logs from a task in Argo?

我正在使用 Argo,对工作流示例的工作流有疑问。 (https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-of-workflows.yaml)

再次更新

如下所述,这是我需要查看的任务。所以我现在的问题是 - 如何查看任务日志?

我的工作流程完成且没有错误,但没有产生预期的输出。我想查看整个工作流程中其中一个工作流程中的其中一个容器的日志,但我无法获得正确的语法我正在使用以下约定从相关 pod 获取日志。

argo logs -n argo wf-name pod-name

并获得:

workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.360917900Z time="2021-04-05T17:55:43.360Z" level=info msg="Starting Workflow Executor" executorType= version="{untagged 2021-04-05T17:09:35Z 79eb50b42e948466f82865b8a79756b57f9b66d9 untagged clean go1.15.7 gc linux/amd64}"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.362737800Z time="2021-04-05T17:55:43.362Z" level=info msg="Creating a docker executor"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.362815200Z time="2021-04-05T17:55:43.362Z" level=info msg="Executor (version: untagged, build_date: 2021-04-05T17:09:35Z) initialized (pod: argo/workflow-of-workflows-k8fm5-3824346685) with template:\n{\"name\":\"run\",\"inputs\":{\"parameters\":[{\"name\":\"runTemplate\",\"value\":\"demo1run.yaml\"}]},\"outputs\":{},\"metadata\":{},\"resource\":{\"action\":\"create\",\"manifest\":\"# Example of using a hard-wired artifact location from a HTTP URL.\napiVersion: argoproj.io/v1alpha1\nkind: Workflow\nmetadata:\n  generateName: message-passing-1-\n  namespace: argo\nspec:\n  serviceAccountName: argo\n  entrypoint: entrypoint\n\n  templates:\n\n  - name: echo\n    container:\n      image: weilidma/curl:0.4\n      command:\n        - \\"/bin/bash\\"\n        - \\"-c\\"\n      args:\n        - \\"cat /mnt/raw/raw1.json  \u0026\u0026 exit\\"\n      volumeMounts:\n        - name: raw-p1-vol\n          mountPath: /mnt/raw\n        - name: log-p1-vol\n          mountPath: /mnt/logs/\n\n  - name: process1\n    container:\n      image: weilidma/curl:0.4\n      command: \n        - \\"/bin/bash\\"\n        - \\"-c\\"\n      args: \n        - \\"jq \\u0027[.data[].Platform |= test(\\u0022Healy\\u0022) | .[][] | select(.Platform == true) | {survey: .Survey, url: .\\u0022Data Access\\u0022}]\\u0027 /mnt/raw/raw1.json \u003e /mnt/processed/filtered1.json \u0026\u0026 exit\\"\n      volumeMounts:\n        - name: raw-p1-vol\n          mountPath: /mnt/raw/\n        - name: processed-p1-vol\n          mountPath: /mnt/processed/\n        - name: log-p1-vol\n          mountPath: /mnt/logs/\n\n  - name: process2\n    container:\n      image: weilidma/curl:0.4\n      command: \n        - \\"/bin/bash\\"\n        - \\"-c\\"\n      args: \n        - \\"jq \\u0027[.data[].Platform |= test(\\u0022Healy\\u0022) | .[][] | select(.Platform == true) | {survey: .Survey, url: .\\u0022Data Access\\u0022}]\\u0027 /mnt/raw/raw2.json \u003e /mnt/processed/filtered2.json \u0026\u0026 exit\\"\n      volumeMounts:\n        - name: raw-p2-vol\n          mountPath: /mnt/raw/\n        - name: processed-p2-vol\n          mountPath: /mnt/processed/\n        - name: log-p2-vol\n          mountPath: /mnt/logs/\n\n  - name: join\n    container:\n      image: weilidma/curl:0.4\n      command: \n        - \\"/bin/bash\\"\n        - \\"-c\\"\n      args: \n        - \\"jq -n --slurpfile f1 /mnt/processed1/filtered1.json --slurpfile f2 /mnt/processed2/filtered2.json -f .jq/join.jq --arg field \\u0022survey\\u0022 \u003e /mnt/processed1/output.json \u0026\u0026 exit\\"\n      volumeMounts:\n        - name: processed-p1-vol\n          mountPath: /mnt/processed1/\n        - name: processed-p2-vol\n          mountPath: /mnt/processed2/\n        - name: log-p1-vol\n          mountPath: /mnt/logs1/\n        - name: log-p2-vol\n          mountPath: /mnt/logs2/\n\n  - name: egress\n    inputs:\n      parameters:\n      - name: ipaddr\n    container:\n      image: weilidma/curl:0.4\n      command: \n        - \\"/bin/bash\\"\n        - \\"-c\\"\n      args: \n        - \\"cat /mnt/processed/output.json \u0026\u0026 exit\\"\n      volumeMounts:\n        - name: processed-p1-vol\n          mountPath: /mnt/processed/\n        - name: log-p1-vol\n          mountPath: /mnt/logs/\n\n  - dag:\n      tasks:\n      - name: echo\n        template: echo\n        dependencies:\n      - name: p1\n        template: process1\n        dependencies:\n\n      - name: p2\n        template: process2\n        dependencies:\n\n      - name: j\n        template: join\n        dependencies:\n        - p1\n        - p2\n\n      - name: e\n        template: egress\n        arguments:\n          parameters: \n            - name: ipaddr \n              value: 'https://192.241.129.100'\n        dependencies:\n        - j\n\n    name: entrypoint\n\"}}"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.362847900Z time="2021-04-05T17:55:43.362Z" level=info msg="Loading manifest to /tmp/manifest.yaml"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.362942100Z time="2021-04-05T17:55:43.362Z" level=info msg="kubectl create -f /tmp/manifest.yaml -o json"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.837625500Z time="2021-04-05T17:55:43.837Z" level=info msg="Resource: argo/Workflow.argoproj.io/message-passing-1-t8749. SelfLink: /apis/argoproj.io/v1alpha1/namespaces/argo/workflows/message-passing-1-t8749"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.837636900Z time="2021-04-05T17:55:43.837Z" level=info msg="Starting SIGUSR2 signal monitor"
workflow-of-workflows-k8fm5-3824346685: 2021-04-05T17:55:43.837696900Z time="2021-04-05T17:55:43.837Z" level=info msg="No output parameters"

根据此输出,容器名称似乎是 argo/Workflow.argoproj.io/message-passing-1-t8749 但是当我将其添加到末尾时出现错误。以下是我尝试过的命令:

argo logs -n argo workflow-of-workflows-k8fm5 workflow-of-workflows-k8fm5-3824346685 -c argo/Workflow.argoproj.io/message-passing-1-t8749

argo logs -n argo workflow-of-workflows-k8fm5 workflow-of-workflows-k8fm5-3824346685 -c message-passing-1-t8749

A​​rgo Workflows pod 上的默认容器名称是 initmainwait

我不确定 message-passing-1-t8749 指的是什么,但它可能是“step/task 名称。”

感谢 ArgoProj 的 Alex!

这是一个我不知道的命令:

kubectl 获取工作流

将列出(惊喜)工作流程!从那里,我可以看到嵌入到更大工作流中的各个工作流。