@@ -4,25 +4,44 @@ Python clients for talking to a [kubernetes](http://kubernetes.io/) cluster.
44
55## Example
66
7- ```python
8- from __future__ import absolute_import
7+ list all pods:
98
9+ ```python
1010import k8sutil
1111import k8sclient
1212import os
1313
1414# Configs can be set in Configuration class directly or using helper utility
1515k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
1616
17- # Prior to python 3.4 hosts with ip-addresses cannot be verified for SSL. this
18- # utility function fixes that.
19- k8sutil.fix_ssl_hosts_with_ipaddress()
20-
2117v1=k8sclient.CoreV1Api()
22- print "Listing pods with their IPs:"
23- ret = v1.list_pod_for_all_namespaces()
18+ print( "Listing pods with their IPs:")
19+ ret = v1.list_pod_for_all_namespaces(watch=False )
2420for i in ret.items:
25- print "%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name)
21+ print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
22+ ```
23+
24+ watch on namespace object:
25+
26+ ```python
27+ import k8sutil
28+ import k8sclient
29+ import os
30+
31+
32+ # Configs can be set in Configuration class directly or using helper utility
33+ k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
34+
35+ v1 = k8sclient.CoreV1Api()
36+ count = 10
37+ watch = k8sutil.Watch()
38+ for event in watch.stream(v1.list_namespace, _request_timeout=60):
39+ print("Event: %s %s" % (event['type'], event['object'].metadata.name))
40+ count -= 1
41+ if not count:
42+ watch.stop()
43+
44+ print("Ended.")
2645```
2746
2847More examples can be found in [examples](examples/) folder. To run examples, run this command:
@@ -33,6 +52,7 @@ python -m examples.example1
3352
3453(replace example1 with the example base filename)
3554
55+
3656# Generated client README
3757
3858
0 commit comments