ls containers.sh

From wikieduonline
Revision as of 15:19, 28 September 2023 by Welcome (talk | contribs) (Created page with "{{lc}} #/bin/bash list_containers_for_cluster () { kubectl get --no-headers pods -A -o custom-columns=":metadata.namespace,:metadata.name" | while read line; do...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


#/bin/bash

list_containers_for_cluster () {
  kubectl get --no-headers pods -A -o custom-columns=":metadata.namespace,:metadata.name"  | while read line; do  for i in "$line"; do set -- $i; kubectl get pods -n $1 $2 -o jsonpath='{.spec.containers[*].name}'; xargs -n1; done; done

}

CLUSTERS=$(kubectl-ctx)
for CLUSTER in $CLUSTERS; do
  kubectl-ctx $CLUSTER
  echo "==== CLUSTER: $CLUSTER ====="
  list_containers_for_cluster | sed  s/^/"Cluster: $CLUSTER "/ 
done


Advertising: