0

团队,我有输出,我想在它前面加上一个 url。

kubectl get nodes -l nodeGroup=gpu -o wide --no-headers -o json | jq '.items[] | .metadata.name, .metadata.labels."team.com/cordon-reason"' | awk '{print $1}' | paste - -

输出

"node1" "testing"
"node2" null

预期产出

"node1" "https://jira.test.com/testing"
"node2" "https://jira.test.com/null"
4

2 回答 2

0

在我看来你想要的:

jq -r '.items[] | [.metadata.name, "https://jira.test.com/\(.metadata.labels["test.com/cordon-reason"])"] | @tsv'
于 2020-01-29T03:46:29.963 回答
0

aah:刚刚想通,但这是正确的方法吗?

-o json | jq '.items[] | .metadata.name, .metadata.labels."test.com/cordon-reason"' | awk '{print $1}' | paste - - | xargs -l1 -- sh -c 'echo $1 https://jira.test.com/$2' --

输出

node1 https://jira.test.com/testing
node2 https://jira.test.com/null
于 2020-01-29T03:41:05.017 回答