Difference between revisions of "Ls containers.sh"

From wikieduonline
Jump to navigation Jump to search
(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...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{lc}}
 
{{lc}}
  
 
+
ls_containers.sh
 
  #/bin/bash
 
  #/bin/bash
 
   
 
   
Line 16: Line 16:
  
  
 +
== Related ==
 +
* [[List containers on a POD]]
 +
 +
== See also ==
 
* {{kubectl get pods}}
 
* {{kubectl get pods}}
* {{K8s}}
 

Latest revision as of 15:20, 28 September 2023

ls_containers.sh
#/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


Related[edit]

See also[edit]

Advertising: