Managing container stdout and stderr logs
In the Unix and Linux OSs, there are three I/O streams, called STDIN
, STDOUT
, and STDERR
. Here, we’ll talk about STDOUT
and STERR
in Linux containers, which are typically what the kubectl logs
command shows to us.
STDOUT
is usually a command’s normal output, and STDERR
is typically used to output error messages. Kubernetes uses the kubectl logs <podname>
command to log STDOUT
and STDERR
. It looks like the following when we use the command to log the nginx
pod that we deployed in this chapter:
kubectl logs nginx
The output should look like the following:
Figure 8.10 – kubectl logs nginx pod
Now, we’ll use a container to write text to the standard output stream with a frequency of once per second. We can do this by deploying a new pod. The following is an example of a YAML manifest for this pod:
apiVersion: v1
kind: Pod
metadata:
name: logger
spec...