Skip to content

Instantly share code, notes, and snippets.

@chiradeep
Created September 21, 2018 16:38
Show Gist options
  • Save chiradeep/80a76a661309b193a458351814bf398f to your computer and use it in GitHub Desktop.
Save chiradeep/80a76a661309b193a458351814bf398f to your computer and use it in GitHub Desktop.
Watch for changes in Endpoints using K8s native Python client
from kubernetes import client, config, watch
config.load_kube_config()
api_v1 = client.CoreV1Api()
def watch_endpoints():
w = watch.Watch()
for event in w.stream(api_v1.list_namespaced_endpoints, "default"):
print(event)
if __name__ == '__main__':
watch_endpoints()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment