-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stream Pod logs with a generator (#182)
- Loading branch information
1 parent
d7b2b28
commit 4223da8
Showing
5 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Inspecting resources | ||
|
||
## Reading Pod logs | ||
|
||
Print out the logs from a Pod. | ||
|
||
`````{tab-set} | ||
````{tab-item} Sync | ||
```python | ||
from kr8s.objects import Pod | ||
pod = Pod.get("my-pod", namespace="ns") | ||
for line in pod.logs(): | ||
print(line) | ||
``` | ||
```` | ||
````{tab-item} Async | ||
```python | ||
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 and keep following until a timeout or the Pod is deleted. | ||
|
||
`````{tab-set} | ||
````{tab-item} Sync | ||
```python | ||
from kr8s.objects import Pod | ||
pod = Pod.get("my-pod", namespace="ns") | ||
for line in pod.logs(follow=True, timeout=3600): | ||
print(line) | ||
``` | ||
```` | ||
````{tab-item} Async | ||
```python | ||
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) | ||
``` | ||
```` | ||
````` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters