()
| 57 | |
| 58 | |
| 59 | async def main(): |
| 60 | |
| 61 | while True: |
| 62 | |
| 63 | try: |
| 64 | |
| 65 | # it works only if this script is run by K8s as a POD |
| 66 | config.load_incluster_config() |
| 67 | |
| 68 | v1 = client.CoreV1Api() |
| 69 | print("Listing pods with their IPs:") |
| 70 | ret = await v1.list_pod_for_all_namespaces() |
| 71 | |
| 72 | for i in ret.items: |
| 73 | print(i.status.pod_ip, i.metadata.namespace, i.metadata.name) |
| 74 | |
| 75 | except Exception: |
| 76 | traceback.print_exc(file=sys.stdout) |
| 77 | |
| 78 | finally: |
| 79 | print("sleep 10s") |
| 80 | await asyncio.sleep(10) |
| 81 | |
| 82 | |
| 83 | if __name__ == "__main__": |
no test coverage detected