Add an in cluster config example
This commit is contained in:
parent
5521d8475c
commit
987cda1c71
18
examples/in_cluster_config.py
Normal file
18
examples/in_cluster_config.py
Normal 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()
|
||||
Loading…
Reference in New Issue
Block a user