Merge branch 'work-around-kubectl-logs-bug' into qconsf2018

This commit is contained in:
Jerome Petazzoni
2018-11-01 19:45:45 -05:00
2 changed files with 54 additions and 0 deletions

View File

@@ -279,6 +279,46 @@ It appears that *all the pods* are serving requests at the moment.
---
## Working around `kubectl logs` bugs
- That last command didn't show what we needed
- We mentioned earlier that regression affecting `kubectl logs` ...
(see [#70554](https://github.com/kubernetes/kubernetes/issues/70554) for more details)
- Let's work around the issue by executing `kubectl logs` one pod at a time
- For convenience, we'll define a little shell function
---
## Our helper function
- The function `ktail` below will:
- list the names of all pods matching a selector
- display the last line of log for each pod
.exercise[
- Define `ktail`:
```bash
ktail () {
kubectl get pods -o name -l $1 |
xargs -rn1 kubectl logs --tail 1
}
```
- Try it:
```bash
ktail app=rng
```
]
---
## The magic of selectors
- The `rng` *service* is load balancing requests to a set of pods

View File

@@ -295,6 +295,20 @@ Unfortunately, `--follow` cannot (yet) be used to stream the logs from multiple
---
## `kubectl logs -l ... --tail N`
- With Kubernetes 1.12 (and up to at least 1.12.2), the last command shows multiple lines
- This is a regression when `--tail` is used together with `-l`/`--selector`
- It always shows the last 10 lines of output for each container
(instead of the number of lines specified on the command line)
- See [#70554](https://github.com/kubernetes/kubernetes/issues/70554) for details
---
## Aren't we flooding 1.1.1.1?
- If you're wondering this, good question!