System plugins (addons) use Kubernetes resources, such as DaemonSets and deployments, to provide features such as storage and networking for a cluster. These resources are deployed in the kube-system namespace. This topic describes how to configure log collection for major system plugins, such as storage, network, and Auto Scaling plugins.
Prerequisites
The log collection add-on is installed.
For Logtail: The
alibaba-log-controllerversion is0.2.0.0-76648ee-aliyunor later.If the
alibaba-log-controllerversion is outdated, upgrade the Logtail add-on.For LoongCollector: All versions are supported.
CoreDNS is upgraded to the latest version. See Manage components.
Step 1: Create a log configuration file for a system plugin
ACK log collection is extended using a CustomResourceDefinition (CRD). When you deploy an AliyunLogConfig CRD configuration, the Log Controller automatically creates the required collection configurations and report resources for Simple Log Service. For more information about how to create a custom resource, see Manage custom resources.
Use the following examples to create an AliyunLogConfig configuration file for the storage, Terway network, Flannel network, or Auto Scaling plugins.
-
Log configuration example for the CSI storage plugin:
apiVersion: log.alibabacloud.com/v1alpha1 kind: AliyunLogConfig metadata: # The configuration name must be unique in the Kubernetes cluster. name: k8s-csi-log namespace: kube-system spec: # The name of the Logstore for log uploads. logstore: k8s-csi-log # The details of the Logtail configuration. logtailConfig: # The input type for Docker standard output is "plugin". inputType: plugin # The name of the Logtail configuration. It must be the same as metadata.name. configName: k8s-csi-log inputDetail: plugin: inputs: - # The input type. type: service_docker_stdout detail: # Collect stdout and stderr. Stdout: true Stderr: true K8sNamespaceRegex: "^kube-system$" K8sPodRegex: "^csi.*$" -
Log configuration example for the Terway network plugin:
apiVersion: log.alibabacloud.com/v1alpha1 kind: AliyunLogConfig metadata: # The configuration name must be unique in the Kubernetes cluster. name: k8s-terway-log namespace: kube-system spec: # The name of the Logstore for log uploads. logstore: k8s-terway-log # The details of the Logtail configuration. logtailConfig: # The input type for Docker standard output is "plugin". inputType: plugin # The name of the Logtail configuration. It must be the same as metadata.name. configName: k8s-terway-log inputDetail: plugin: inputs: - # The input type. type: service_docker_stdout detail: # Collect stdout and stderr. Stdout: true Stderr: true K8sNamespaceRegex: "^kube-system$" K8sPodRegex: "^terway-eniip.*$" -
Log configuration example for the Flannel network plugin:
apiVersion: log.alibabacloud.com/v1alpha1 kind: AliyunLogConfig metadata: # The configuration name must be unique in the Kubernetes cluster. name: k8s-flannel-log namespace: kube-system spec: # The name of the Logstore for log uploads. logstore: k8s-flannel-log # The details of the Logtail configuration. logtailConfig: # The input type for Docker standard output is "plugin". inputType: plugin # The name of the Logtail configuration. It must be the same as metadata.name. configName: k8s-flannel-log inputDetail: plugin: inputs: - # The input type. type: service_docker_stdout detail: # Collect stdout and stderr. Stdout: true Stderr: true K8sNamespaceRegex: "^kube-system$" K8sPodRegex: "^kube-flannel-ds.*$" -
Log configuration example for the Auto Scaling plugin:
apiVersion: log.alibabacloud.com/v1alpha1 kind: AliyunLogConfig metadata: # The configuration name must be unique in the Kubernetes cluster. name: k8s-cluster-autoscaler-log namespace: kube-system spec: # The name of the Logstore for log uploads. logstore: k8s-cluster-autoscaler-log # The details of the Logtail configuration. logtailConfig: # The input type for Docker standard output is "plugin". inputType: plugin # The name of the Logtail configuration. It must be the same as metadata.name. configName: k8s-cluster-autoscaler-log inputDetail: plugin: inputs: - # The input type. type: service_docker_stdout detail: # Collect stdout and stderr. Stdout: true Stderr: true K8sNamespaceRegex: "^kube-system$" K8sPodRegex: "^cluster-autoscaler.*$"
Step 2: View logs
For more information about how to view logs, see Collect logs from containers in an ACK cluster.