Inspecting Resources#

Read Pod logs#

Print out the logs from a Pod using Pod.logs().

from kr8s.objects import Pod

pod = Pod.get("my-pod", namespace="ns")
for line in pod.logs():
    print(line)
from kr8s.asyncio.objects import Pod

pod = await Pod.get("my-pod", namespace="ns")
async for line in pod.logs():
    print(line)

Follow Pod logs until a timeout#

Print out all the logs from a Pod using Pod.logs() and keep following until a timeout or the Pod is deleted.

from kr8s.objects import Pod

pod = Pod.get("my-pod", namespace="ns")
for line in pod.logs(follow=True, timeout=3600):
    print(line)
from kr8s.asyncio.objects import Pod

pod = await Pod.get("my-pod", namespace="ns")
async for line in pod.logs(follow=True, timeout=3600):
    print(line)