-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
identifies tetragon pod managing a pod
Signed-off-by: sandeshv <sandeshkv92@gmail.com>
- Loading branch information
1 parent
85842ad
commit 62452ed
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Authors of Cilium | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
# Given a pod name and namespace, get the corresponding tetragon pod name. | ||
|
||
K8S_NAMESPACE="${K8S_NAMESPACE:-kube-system}" | ||
|
||
if [[ $# -ne 2 ]] | ||
then | ||
echo "Usage: $(basename "$0") <pod> <namespace>" >&2 | ||
exit 1 | ||
fi | ||
TARGET_POD_NAME="$1" | ||
TARGET_POD_NAMESPACE="$2" | ||
|
||
# Get the target pod's node. | ||
target_pod_node="$(kubectl get pod "${TARGET_POD_NAME}" -n "${TARGET_POD_NAMESPACE}" --no-headers -o custom-columns=:.spec.nodeName)" | ||
if [[ -z "${target_pod_node}" ]] | ||
then | ||
echo "pod ${TARGET_POD_NAMESPACE}/${TARGET_POD_NAME} has no node assigned" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Get the Cilium pod running on the target pod's node (using exact node matching). | ||
kubectl get pods -n "${K8S_NAMESPACE}" -l app.kubernetes.io/name=tetragon --no-headers -o custom-columns=:.metadata.name,:.spec.nodeName | awk -v node="${target_pod_node}" '$2==node {print $1}' |