Skip to content

Commit b2f9755

Browse files
authored
Create test_pod_logs.py
This file is to test whether empty line are printed when watch function in the kubernetes python client is used.
1 parent d1adc8a commit b2f9755

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

kubernetes/test/test_pod_logs.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from kubernetes import client, config, watch
2+
3+
pod_name = "demo-bug"
4+
5+
6+
config.load_kube_config()
7+
8+
9+
api = client.CoreV1Api()
10+
namespace = config.list_kube_config_contexts()[1]["context"]["namespace"]
11+
12+
pod_manifest = {
13+
"apiVersion": "v1",
14+
"kind": "Pod",
15+
"metadata": {
16+
"name": pod_name,
17+
},
18+
"spec": {
19+
"containers": [{"image": "hello-world", "name": pod_name}],
20+
},
21+
}
22+
api.create_namespaced_pod(body=pod_manifest, namespace=namespace)
23+
24+
input("\n\nSubmit when running\n\n")
25+
26+
w = watch.Watch()
27+
for e in w.stream(
28+
api.read_namespaced_pod_log,
29+
name=pod_name,
30+
namespace=namespace,
31+
follow=True,
32+
):
33+
print(e)

0 commit comments

Comments
 (0)