我想从 kubernetes 上可用的 pod 列表中提取 pod 名称。例如,对于以下命令
kubectl get pods -n 命名空间
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 2 46d
pod2 1/1 Running 0 46d
test-pod3-yy 0/1 ImagePullBackOff 0 338d
test-pod3-xx 1/1 Running 0 255d
Run Code Online (Sandbox Code Playgroud)
test-pod3-xx我想使用 shell 脚本提取 pod 。目前这是我正在使用的命令
POD_NAME=$(kubectl get pods -n namespace | grep testpod-3 | cut -d' ' -f1)
Run Code Online (Sandbox Code Playgroud)
这样我就得到了两个 Pod test-pod3-yy,test-pod3-xx但我想提取处于运行状态的 Pod。我怎样才能做到这一点?