-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy-client.py
59 lines (45 loc) · 1.48 KB
/
py-client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from kubernetes import client, config
from pprint import pprint
import sys
import time
config.load_kube_config()
v1 = client.CoreV1Api()
apps = client.AppsV1Api()
# print("Listing pods with their IPs:")
# ret = v1.list_pod_for_all_namespaces(watch=False)
# for i in ret.items:
# print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
# while("true"):
# try:
# res = apps.read_namespaced_deployment_status('argo-ui', 'argo')
# except:
# print("Oops!",sys.exc_info()[0],"occured.")
# time.sleep(3)
# else:
# pprint(res.status)
# if res.status.available_replicas == None:
# print("/n/n not yet avalialble")
# time.sleep(1)
# else:
# break
def wait_for_resource(name, namespace):
start = time.time()
while(True):
try:
res = apps.read_namespaced_deployment_status(name, namespace)
except:
print("Oops!",sys.exc_info()[0],"occured.")
time.sleep(3)
else:
pprint(res.status)
if res.status.available_replicas == None:
print("/n/n not yet avalialble")
time.sleep(1)
else:
break
end = time.time()
return "up", end - start
# res = apps.read_namespaced_stateful_set_status('hlf-peer--merchant1--peer0', 'default')
# pprint(res.status)
# res = apps.read_namespaced_deployment_status('hello-web', 'default')
# pprint(res.status)