@@ -75,6 +75,37 @@ appending a container name to the command, with a `-c` flag, like so:
75
75
kubectl logs counter -c count
76
76
```
77
77
78
+
79
+ ### Container log streams
80
+
81
+ {{< feature-state feature_gate_name="PodLogsQuerySplitStreams" >}}
82
+
83
+ As an alpha feature, the kubelet can split out the logs from the two standard streams produced
84
+ by a container: [ standard output] ( https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout) )
85
+ and [ standard error] ( https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr) ) .
86
+ To use this behavior, you must enable the ` PodLogsQuerySplitStreams `
87
+ [ feature gate] ( /docs/reference/command-line-tools-reference/feature-gates/ ) .
88
+ With that feature gate enabled, Kubernetes {{< skew currentVersion >}} allows access to these
89
+ log streams directly via the Pod API. You can fetch a specific stream by specifying the stream name (either ` Stdout ` or ` Stderr ` ),
90
+ using the ` stream ` query string. You must have access to read the ` log ` subresource of that Pod.
91
+
92
+ To demonstrate this feature, you can create a Pod that periodically writes text to both the standard output and error stream.
93
+
94
+ {{% code_sample file="debug/counter-pod-err.yaml" %}}
95
+
96
+ To run this pod, use the following command:
97
+
98
+ ``` shell
99
+ kubectl apply -f https://k8s.io/examples/debug/counter-pod-err.yaml
100
+ ```
101
+
102
+ To fetch only the stderr log stream, you can run:
103
+
104
+ ``` shell
105
+ kubectl get --raw " /api/v1/namespaces/default/pods/counter-err/log?stream=Stderr"
106
+ ```
107
+
108
+
78
109
See the [ ` kubectl logs ` documentation] ( /docs/reference/generated/kubectl/kubectl-commands#logs )
79
110
for more details.
80
111
0 commit comments