@cryptotaxi247 / netdata-1 / commits / a3a46cb6d

Get all k8s container names (#6885)

Fixes #6878 All containers in a kubernetes pod were not being resolved, as there was a hard-limit on the first item in `containerStatuses[]` Thanks to @majodev for the catch and the fix

Chris Akritidis committed Sep 18, 2019 at 13:46 UTC a3a46cb6d5147a1e8159de468523cd91d08bc2cf
1 file changed +1 -1
collectors/cgroups.plugin/cgroup-name.sh.in
+1 -1
@@ -86,7 +86,7 @@ function k8s_get_name() {
86 if command -v jq >/dev/null 2>&1; then
87 NAME="$(
88 curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" "https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/pods" |
89 - jq -r '.items[] | "k8s_\(.metadata.namespace)_\(.metadata.name)_\(.metadata.uid)_\(.status.containerStatuses[0].name) \(.status.containerStatuses[0].containerID)"' |
89 + jq -r '.items[] | "k8s_\(.metadata.namespace)_\(.metadata.name)_\(.metadata.uid)_" + (.status.containerStatuses[]? | "\(.name) \(.containerID)")' |
90 grep "$id" |
91 cut -d' ' -f1
92 )"