Kubernetes container logs that are collected can be used for troubleshooting, performance optimization, security auditing, and resource utilization analysis. Simple Log Service allows you to collect container logs from Kubernetes clusters in DaemonSet mode or Sidecar mode. This topic describes the procedures, advantages, and disadvantages of log collection in the two modes.
Collection modes
Collection mode | Advantage | Disadvantage |
DaemonSet | Provides simple O&M, low resource usage, and flexible configurations. You can collect container stdout and stderr logs. You can also collect container text logs. | Logtail collects logs from all containers on a DaemonSet-specific node. However, in this mode, performance bottleneck issues may occur on Logtail, and containers are loosely isolated. |
Sidecar | In Sidecar mode, a Sidecar container is created for each container from which you want to collect logs. In this mode, Logtail provides good performance, and tenants are completely isolated. | None |
Log collection configurations
You can create log collection configurations in the Simple Log Service console or by using custom resource definitions (CRDs). The following table describes the differences between the two modes.
Item | CRD | Console |
Operation complexity | Easy | Moderate |
Feature | All configurations that the Simple Log Service console supports and advanced configurations that the console does not support | Moderate |
Ease of use | Moderate | Low |
Network connections | Connects to a Kubernetes cluster | Connects to the Internet |
Integration with container applications | Supported | Not supported |
Authentication method | Authenticated by Kubernetes | Authentication based on Alibaba Cloud accounts |
Log collection procedures
To collect logs in DaemonSet mode, perform the following steps:
Create a log collection configuration.
You can create log collection configurations in the Simple Log Service console or by using CRDs to collect container logs from Kubernetes clusters.
Use the Simple Log Service console to collect container text logs in DaemonSet mode
Use the Simple Log Service console to collect container stdout and stderr logs in DaemonSet mode
NoteIf you use CRDs, resources such as projects, Logstores, indexes, machine groups, and Logtail configurations are automatically created. In addition, this mode leads to better integration with Kubernetes. We recommend that you use this mode. If you use the Simple Log Service console, you need to only perform simple operations. The first time you use Simple Log Service to collect container logs, we recommend that you use this mode.
To collect logs in Sidecar mode, perform the following steps:
Install Sidecar and create a log collection configuration.
You can create log collection configurations in the Simple Log Service console or by using CRDs to collect container logs from Kubernetes clusters.