@@ -30,23 +30,25 @@ def main():
3030 return
3131 contexts = [context ['name' ] for context in contexts ]
3232 active_index = contexts .index (active_context ['name' ])
33- option , _ = pick (contexts , title = "Pick the context to load" ,
34- default_index = active_index )
35- # Configs can be set in Configuration class directly or using helper
36- # utility
37- config .load_kube_config (context = option )
38-
39- print ("Active host is %s" % configuration .Configuration ().host )
40-
41- v1 = client .CoreV1Api ()
42- print ("Listing pods with their IPs:" )
43- ret = v1 .list_pod_for_all_namespaces (watch = False )
44- for item in ret .items :
45- print (
46- "%s\t %s\t %s" %
47- (item .status .pod_ip ,
48- item .metadata .namespace ,
49- item .metadata .name ))
33+ cluster1 , first_index = pick (contexts , title = "Pick the first context" ,
34+ default_index = active_index )
35+ cluster2 , _ = pick (contexts , title = "Pick the second context" ,
36+ default_index = first_index )
37+
38+ client1 = client .CoreV1Api (
39+ api_client = config .new_client_from_config (context = cluster1 ))
40+ client2 = client .CoreV1Api (
41+ api_client = config .new_client_from_config (context = cluster2 ))
42+
43+ print ("\n List of pods on %s:" % cluster1 )
44+ for i in client1 .list_pod_for_all_namespaces ().items :
45+ print ("%s\t %s\t %s" %
46+ (i .status .pod_ip , i .metadata .namespace , i .metadata .name ))
47+
48+ print ("\n \n List of pods on %s:" % cluster2 )
49+ for i in client2 .list_pod_for_all_namespaces ().items :
50+ print ("%s\t %s\t %s" %
51+ (i .status .pod_ip , i .metadata .namespace , i .metadata .name ))
5052
5153
5254if __name__ == '__main__' :
0 commit comments