Add an in cluster config example

This commit is contained in:
avi 2017-06-19 13:55:38 +05:30
parent 5521d8475c
commit 987cda1c71

View File

@ -0,0 +1,18 @@
# Simple example to show loading config from the cluster
from kubernetes import client, config
def main():
config.load_incluster_config()
v1 = client.CoreV1Api()
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))
if __name__ == '__main__':
main()