ACK system components — including storage, networking, and auto scaling components — run as DaemonSets, Deployments, and other Kubernetes resources in the kube-system namespace. This topic explains how to configure log collection for these components using Simple Log Service (SLS) so you can inspect component behavior during debugging.
The following components are supported:
| Component | Type | Pod name prefix | K8sPodRegex value |
|---|---|---|---|
| Container Storage Interface (CSI) plug-in | Storage | csi | ^csi.*$ |
| Terway plug-in | Networking | terway-eniip | ^terway-eniip.*$ |
| Flannel plug-in | Networking | kube-flannel-ds | ^kube-flannel-ds.*$ |
| Cluster autoscaler | Auto scaling | cluster-autoscaler | ^cluster-autoscaler.*$ |
Prerequisites
Before you begin, make sure that:
The logtail-ds component is installed in your cluster. ACK installs logtail-ds by default when you create a cluster. If it is not installed, see Collect log data from containers by using Log Service to install it manually.
The alibaba-log-controller version is 0.2.0.0-76648ee-aliyun or later. To check the version, go to the Components page in the ACK console.
If the version is earlier, update the logtail-ds component. See Manage system components.
Log collection writes data to a Simple Log Service Logstore and incurs ingestion and storage costs. Collect logs only for the components you need to debug.
Step 1: Create log collection configurations
Log collection configurations are implemented as AliyunLogConfig custom resources. When you create an AliyunLogConfig object, alibaba-log-controller automatically configures the corresponding Logstore and collection rules in Simple Log Service.
All configurations use inputType: plugin with service_docker_stdout to collect stdout and stderr streams from Pods in the kube-system namespace. The K8sPodRegex field targets specific Pods by name prefix.
For general guidance on creating custom resource objects, see Manage custom resources.
CSI plug-in
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
# Must be unique within the cluster.
name: k8s-csi-log
namespace: kube-system
spec:
# Target Logstore name.
logstore: k8s-csi-log
logtailConfig:
inputType: plugin
# Must match metadata.name.
configName: k8s-csi-log
inputDetail:
plugin:
inputs:
- type: service_docker_stdout
detail:
Stdout: true
Stderr: true
K8sNamespaceRegex: "^kube-system$"
K8sPodRegex: "^csi.*$"Terway plug-in
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: k8s-terway-log
namespace: kube-system
spec:
logstore: k8s-terway-log
logtailConfig:
inputType: plugin
configName: k8s-terway-log
inputDetail:
plugin:
inputs:
- type: service_docker_stdout
detail:
Stdout: true
Stderr: true
K8sNamespaceRegex: "^kube-system$"
K8sPodRegex: "^terway-eniip.*$"Flannel plug-in
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: k8s-flannel-log
namespace: kube-system
spec:
logstore: k8s-flannel-log
logtailConfig:
inputType: plugin
configName: k8s-flannel-log
inputDetail:
plugin:
inputs:
- type: service_docker_stdout
detail:
Stdout: true
Stderr: true
K8sNamespaceRegex: "^kube-system$"
K8sPodRegex: "^kube-flannel-ds.*$"Cluster autoscaler
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: k8s-cluster-autoscaler-log
namespace: kube-system
spec:
logstore: k8s-cluster-autoscaler-log
logtailConfig:
inputType: plugin
configName: k8s-cluster-autoscaler-log
inputDetail:
plugin:
inputs:
- type: service_docker_stdout
detail:
Stdout: true
Stderr: true
K8sNamespaceRegex: "^kube-system$"
K8sPodRegex: "^cluster-autoscaler.*$"Step 2: View log files
After alibaba-log-controller processes the configuration, logs appear in the Simple Log Service console under the Logstore you specified (for example, k8s-csi-log).
To query and view the collected logs, see Step 4: View log data.