From 7e001d6069b9679b87c96add581137f3c5a51ad7 Mon Sep 17 00:00:00 2001 From: Chris Akritidis <43294513+cakrit@users.noreply.github.com> Date: Wed, 10 Jun 2020 09:57:01 -0700 Subject: Ensures we get consistent kubernetes cgroup container names, regardless of whether netdata runs from within a kubernetes pod, or directly on the host machine. (#9303) Fixes #8044 Ensures we get consistent kubernetes cgroup container names, regardless of whether netdata runs from within a kubernetes pod, or directly on the host machine. Additional Information Fixes a bug that was originally fixed in #6885 and re-introduced in #7416. Fixes the seemingly non-functional selector in #7416 --- collectors/cgroups.plugin/cgroup-name.sh.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'collectors/cgroups.plugin') diff --git a/collectors/cgroups.plugin/cgroup-name.sh.in b/collectors/cgroups.plugin/cgroup-name.sh.in index e704196ee4..ab16e673d9 100755 --- a/collectors/cgroups.plugin/cgroup-name.sh.in +++ b/collectors/cgroups.plugin/cgroup-name.sh.in @@ -91,7 +91,7 @@ function k8s_get_name() { KUBE_TOKEN="$(/dev/null 2>&1; then #shellcheck disable=SC2086 - NAME="$(kubectl --kubeconfig=$KUBE_CONFIG get pod --all-namespaces --output='json' | \ - jq -r '.items[] | select(.metadata.uid == "'$id'") | .metadata.name')" + NAME="$(kubectl --kubeconfig=$KUBE_CONFIG get pod --all-namespaces --output='json' | + jq -r '.items[] | "k8s_\(.metadata.namespace)_\(.metadata.name)_\(.metadata.uid)_" + (.status.containerStatuses[]? | "\(.name) \(.containerID)")' | + grep "$id" | + cut -d' ' -f1 + )" else warning "kubectl cannot get pod list, check for configuration file in $KUBE_CONFIG, or set this path to env \$KUBE_CONFIG" fi -- cgit v1.2.3