You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-node/3288-separate-stdout-from-stderr/README.md
+74-79Lines changed: 74 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,8 +171,8 @@ retrieve certain log stream of a container, so it is great to implement this lon
171
171
172
172
### Goals
173
173
174
-
- Enable api-server to return certain log stream of a container
175
-
- Enable users to fetch certain log stream of a container
174
+
- Enable api-server to return specific log stream of a container
175
+
- Enable users to fetch specific log stream of a container
176
176
177
177
### Non-Goals
178
178
@@ -216,21 +216,34 @@ This might be a good place to talk about core concepts and how they relate.
216
216
Add a new field `Stream` to `k8s.io/kubernetes/pkg/apis/core.PodLogOptions`:
217
217
218
218
```go
219
+
// LogStreamType represents the desired log stream type.
220
+
typeLogStreamTypestring
221
+
222
+
const (
223
+
// LogStreamTypeStdout is the stream type for stdout.
224
+
LogStreamTypeStdoutLogStreamType = "stdout"
225
+
// LogStreamTypeStderr is the stream type for stderr.
226
+
LogStreamTypeStderrLogStreamType = "stderr"
227
+
// LogStreamTypeAll represents the combined stdout and stderr.
228
+
LogStreamTypeAllLogStreamType = "all"
229
+
)
230
+
219
231
// PodLogOptions is the query options for a Pod's logs REST call
220
232
typePodLogOptionsstruct {
221
-
...
222
-
// If set, return the given log stream of the container.
223
-
// Otherwise, the combined stdout and stderr from the container is returned.
224
-
// Available values are: "stdout", "stderr", "" (empty string).
225
-
Streamstring
233
+
...
234
+
// If set to "stdout" or "stderr", return the given log stream of the container.
235
+
// If set to "all" or not set, the combined stdout and stderr from the container is returned.
236
+
// Available values are: "stdout", "stderr", "all", "" (empty string).
237
+
// +optional
238
+
StreamLogStreamType
226
239
}
227
240
```
228
241
229
242
When users want to query certain stream from container, they need to add a new query named `stream`
230
243
to the URL, i.e. `/api/v1/namespaces/default/pods/foo/log?stream=stderr&container=nginx`.
231
244
Then the kube-apiserver is able to know the desired `stream` and passes it to the kubelet.
232
245
233
-
To tell kubelet which stream to return, we need to update the `LogLocation` function to make it be aware of
246
+
To tell kubelet which stream to return, we need to update the [`LogLocation`](https://github.com/kubernetes/kubernetes/blob/ba502ee555924a49c1455b0d3fa96ec1e787715d/pkg/registry/core/pod/strategy.go#L398) function to make it be aware of
@@ -265,45 +282,46 @@ Add a new field `Stream` to `k8s.io/api/core/v1.PodLogOptions`:
265
282
typeLogStreamTypestring
266
283
267
284
const (
268
-
// LogStreamTypeStdout is the stream type for stdout.
269
-
LogStreamTypeStdoutLogStreamType = "stdout"
270
-
// LogStreamTypeStderr is the stream type for stderr.
285
+
// LogStreamTypeStdout is the stream type for stdout.
286
+
LogStreamTypeStdoutLogStreamType = "stdout"
287
+
// LogStreamTypeStderr is the stream type for stderr.
271
288
LogStreamTypeStderrLogStreamType = "stderr"
272
-
// LogStreamTypeAll represents the combined stdout and stderr.
273
-
LogStreamTypeAllLogStreamType = ""
289
+
// LogStreamTypeAll represents the combined stdout and stderr.
290
+
LogStreamTypeAllLogStreamType = "all"
274
291
)
275
292
// PodLogOptions is the query options for a Pod's logs REST call.
276
293
typePodLogOptionsstruct {
277
-
...
278
-
// If set, return the given log stream of the container.
279
-
// Otherwise, the combined stdout and stderr from the container is returned.
280
-
// +optional
281
-
StreamLogStreamType
294
+
...
295
+
// If set, return the given log stream of the container.
296
+
// Otherwise, the combined stdout and stderr from the container is returned.
297
+
// +optional
298
+
StreamLogStreamType
282
299
}
300
+
283
301
```
284
302
285
-
In the `getContainerLogs` method of `k8s.io/kubernetes/pkg/kubelet/server.Server`, we examine the `Stream` field
303
+
In the [`getContainerLogs`](https://github.com/kubernetes/kubernetes/blob/ba502ee555924a49c1455b0d3fa96ec1e787715d/pkg/kubelet/server/server.go#L610) method of `k8s.io/kubernetes/pkg/kubelet/server.Server`, we examine the `Stream` field
286
304
of `PodLogOptions` to decide which stream to return:
287
305
288
306
```go
289
307
// getContainerLogs handles containerLogs request against the Kubelet
0 commit comments