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.
This commit is contained in:
Raj Bhargav 2025-03-13 13:57:29 +05:30 committed by GitHub
parent d1adc8a544
commit b2f975537c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,33 @@
from kubernetes import client, config, watch
pod_name = "demo-bug"
config.load_kube_config()
api = client.CoreV1Api()
namespace = config.list_kube_config_contexts()[1]["context"]["namespace"]
pod_manifest = {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": pod_name,
},
"spec": {
"containers": [{"image": "hello-world", "name": pod_name}],
},
}
api.create_namespaced_pod(body=pod_manifest, namespace=namespace)
input("\n\nSubmit when running\n\n")
w = watch.Watch()
for e in w.stream(
api.read_namespaced_pod_log,
name=pod_name,
namespace=namespace,
follow=True,
):
print(e)