Kubernetes Shell Exec All Containers

Luke Arntz on
Filed under Devops
Tagged as k8s kubernetes pod shell

Article Contents


fish script to loop through all pods

This is not great, but a start. Does not take into account pods with multiple containers, and probably other failure cases.

for n in (k get ns -o json | jq -r .items[].metadata.name)
  for p in (k get pods -n $n -o json | jq -r .items[].metadata.name)
    echo -n "$p: "; k exec $p -n $n -- ls /usr/bin/pkexec 2> /dev/null
    echo " "
  end
end

Related Articles

Top