diff options
author | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-09-18 13:46:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-18 13:46:35 +0200 |
commit | a3a46cb6d5147a1e8159de468523cd91d08bc2cf (patch) | |
tree | 872496f9e1dec9616a6c1e4bcae6cb816b511cd0 | |
parent | d09c142dc85eee81f2bb6e929bf12cdc4d8f6b9e (diff) |
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
-rwxr-xr-x | collectors/cgroups.plugin/cgroup-name.sh.in | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/collectors/cgroups.plugin/cgroup-name.sh.in b/collectors/cgroups.plugin/cgroup-name.sh.in index 784c06042d..f7b765bb61 100755 --- a/collectors/cgroups.plugin/cgroup-name.sh.in +++ b/collectors/cgroups.plugin/cgroup-name.sh.in @@ -86,7 +86,7 @@ function k8s_get_name() { if command -v jq >/dev/null 2>&1; then NAME="$( curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" "https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/pods" | - jq -r '.items[] | "k8s_\(.metadata.namespace)_\(.metadata.name)_\(.metadata.uid)_\(.status.containerStatuses[0].name) \(.status.containerStatuses[0].containerID)"' | + jq -r '.items[] | "k8s_\(.metadata.namespace)_\(.metadata.name)_\(.metadata.uid)_" + (.status.containerStatuses[]? | "\(.name) \(.containerID)")' | grep "$id" | cut -d' ' -f1 )" |