首页 > 其他分享 >根据pid获取pod名称

根据pid获取pod名称

时间:2023-02-22 10:47:14浏览次数:38  
标签:tar CID pid 获取 VERSION crictl pod

#!/bin/bash

# 参考https://cloud.tencent.com/developer/article/1664123
# 根据pid获取pod名称
# 需要安装crictl工具
# 指定版本
# VERSION="v1.13.11"
# 获取最新版本
# VERSION=$(wget -qO- -t1 -T2 "https://api.github.com/repos/kubernetes-sigs/cri-tools/releases/latest" | jq -r '.tag_name')
# wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
# tar -xvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin/
podinfo() {
  CID=$(cat /proc/$1/cgroup | awk -F '/' '{print $5}')
  CID=$(echo ${CID:0:8})
  crictl inspect -o go-template --template='{{index .status.labels "io.kubernetes.pod.name"}}' $CID
}

标签:tar,CID,pid,获取,VERSION,crictl,pod
From: https://www.cnblogs.com/xwjh/p/17143499.html

相关文章