Hello and welcome to this lecture. In this lecture
we will talk about various Logging mechanisms in kubernetes. Let us start with logging in Docker. I run
a docker container called event-simulator and all that it does is generate random events simulating a web
server.
These are events streamed to the standard output by the application.
Now, if I were to run the docker container in the background, in a detached mode using the –d option,
I wouldn't see the logs if I wanted to view the logs.
I could use the docker logs command followed by the container ID. The –f option helps us see the
live log trail.
Now back to Kubernetes. We create a pod with the same docker image using the pod definition file.
Once it’s the pod is running, we can view the logs using the kubectl logs command with the pod name.
Use the –f option to stream the logs live just like the docker command.
Now these logs are specific to the container running inside the pod.
As we learned before, Kubernetes PODs can have multiple docker containers in them.
In this case I modify my pod definition file to include an additional container called image-processor.
If you ran the kubectl logs command
now with the pod name, which container’s log would it show? If there are multiple containers within a
pod.
You must specify the name of the container explicitly in the command.
Otherwise it would fail asking you to specify a name.
In this case I will specify the name of the first container event-simulator and that prints the relevant
log messages.
Now, that is the simple logging functionality implemented within Kubernetes.
And that is all that an application developer really needs to know to get started with Kubernetes.
And that is all you really need to know as part of the certification program.
However in the next lecture we will see more about some advanced logging configuration and third party
support for logging in Kubernetes.
We also have a nice demo that shows how a popular logging framework is integrated with kubernetes.
Well that's it for this lecture.
Head over to the coding exercises section and practice working with logs thank you.