Skip to content

Commit 987cda1

Browse files
committed
Add an in cluster config example
1 parent 5521d84 commit 987cda1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/in_cluster_config.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Simple example to show loading config from the cluster
2+
3+
from kubernetes import client, config
4+
5+
6+
def main():
7+
config.load_incluster_config()
8+
9+
v1 = client.CoreV1Api()
10+
print("Listing pods with their IPs:")
11+
ret = v1.list_pod_for_all_namespaces(watch=False)
12+
for i in ret.items:
13+
print("%s\t%s\t%s" %
14+
(i.status.pod_ip, i.metadata.namespace, i.metadata.name))
15+
16+
17+
if __name__ == '__main__':
18+
main()

0 commit comments

Comments
 (0)