Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2. from kubernetes import client, config, watch
  3.  
  4.  
  5. def main():
  6. # Configs can be set in Configuration class directly or using helper
  7. # utility. If no argument provided, the config will be loaded from
  8. # default location.
  9. config.load_kube_config()
  10.  
  11. v1 = client.CoreV1Api()
  12. count = 10
  13. w = watch.Watch()
  14. for event in w.stream(v1.list_namespace, timeout_seconds=10):
  15. print("Event: %s %s" % (event['type'], event['object'].metadata.name))
  16. count -= 1
  17. if not count:
  18. w.stop()
  19.  
  20. print("Ended.")
  21.  
  22.  
  23. if __name__ == '__main__':
  24. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement