Kubernetes Log Forwarding with Syslog
Logs help you troubleshoot issues with your clusters and apps. Sometimes, you might want to send logs somewhere for processing or long-term storage. On a Kubernetes cluster in the IBM Cloud Container Service, you can enable log forwarding for your cluster and choose where your logs are forwarded.
Using the Container Service CLI, you can forward your container logs to a syslog server with one command:
The above command creates a logging configuration to send all container standard output and error logs from the default Kubernetes namespace. These logs are sent using the syslog protocol to
Try it out
In this tutorial, you will forward your logs to an rsyslog instance running in the same cluster.
Create a Kubernetes cluster on the IBM Cloud Container Service and wait for it to become ready. Next, connect
kubectl commands to your cluster with the following command:
Next, create an rsyslog service we can forward logs to.
Start by creating
deploy-rsyslog.yaml with the following contents:
Then run the following:
Then configure your logs to go to the rsyslog service.
Finally, deploy a container to your cluster that generates logs. I like using a
noisy pod to verify that log forwarding is working. Make a
deploy-noisy.yaml file with the following contents:
Finally, create the
Now take a look inside the rsyslog instance to see the logs.
If you see some
Hello world! lines, then you have successfully forwarded logs to your rsyslog service.