System components use DaemonSets, Deployments, and other Kubernetes resources to implement the storage and networking features of Container Service for Kubernetes (ACK) clusters. These Kubernetes resources are deployed in the kube-system namespace. This topic describes how to collect log files of the storage, networking, and auto scaling components.

Prerequisites

  • The logtail-ds component is installed in the cluster.

    When you create an ACK cluster, the system automatically selects the logtail-ds component. If the logtail-ds component is not installed in the cluster, you can manually install it. For more information, see Collect log files from containers by using Log Service.

  • Make sure that the version of alibaba-log-controller is 0.2.0.0-76648ee-aliyun or later. logcontroller

    If an earlier version of alibaba-log-controller is used, you can upgrade the logtail-ds component. For more information about how to upgrade a component, see Manage system components.

Step 1: Create configuration files for collecting log files of system components

Logging configurations can be implemented by using CustomResourceDefinitions (CRDs). You can create custom resource objects of the AliyunLogConfig type. alibaba-log-controller automatically configures Log Service settings and creates log reports based on the created custom resource objects. For more information about how to create custom resource objects, see Manage custom resources.

Create configuration files of the AliyunLogConfig type based on the following examples to collect log files of the storage, Terway, Flannel, and auto scaling components.

  • Example for collecting log files of the Container Storage Interface (CSI) plug-in:
    apiVersion: log.alibabacloud.com/v1alpha1
    kind: AliyunLogConfig
    metadata:
      # The name that you specify must be unique in the cluster. 
      name: k8s-csi-log
      namespace: kube-system
    spec:
      # The name of the Logstore to which the log files are collected. 
      logstore: k8s-csi-log
      # The detailed settings of the Logtail configuration. 
      logtailConfig:
        # The input type of Docker stdout is plugin. 
        inputType: plugin
        # The name of the Logtail configuration. The name must be the same as that specified by the metadata.name field. 
        configName: k8s-csi-log
        inputDetail:
          plugin:
            inputs:
              -
                # The input type. 
                type: service_docker_stdout
                detail:
                  # Collect stdout and stderr streams. 
                  Stdout: true
                  Stderr: true
                  K8sNamespaceRegex: "^kube-system$"
                  K8sPodRegex: "^csi.*$"
  • Example for collecting log files of the Terway plug-in:
    apiVersion: log.alibabacloud.com/v1alpha1
    kind: AliyunLogConfig
    metadata:
      # The name that you specify must be unique in the cluster. 
      name: k8s-terway-log
      namespace: kube-system
    spec:
      # The name of the Logstore to which the log files are collected. 
      logstore: k8s-terway-log
      # The detailed settings of the Logtail configuration. 
      logtailConfig:
      # The input type of Docker stdout is plugin. 
        inputType: plugin
        # The name of the Logtail configuration. The name must be the same as that specified by the metadata.name field. 
        configName: k8s-terway-log
        inputDetail:
          plugin:
            inputs:
              -
                # The input type. 
                type: service_docker_stdout
                detail:
                  # Collect stdout and stderr streams. 
                  Stdout: true
                  Stderr: true
                  K8sNamespaceRegex: "^kube-system$"
                  K8sPodRegex: "^terway-eniip.*$"
  • Example for collecting log files of the Flannel plug-in:
    apiVersion: log.alibabacloud.com/v1alpha1
    kind: AliyunLogConfig
    metadata:
      # The name that you specify must be unique in the cluster. 
      name: k8s-flannel-log
      namespace: kube-system
    spec:
      # The name of the Logstore to which the log files are collected. 
      logstore: k8s-flannel-log
      # The detailed settings of the Logtail configuration. 
      logtailConfig:
        # The input type of Docker stdout is plugin. 
        inputType: plugin
        # The name of the Logtail configuration. The name must be the same as that specified by the metadata.name field. 
        configName: k8s-flannel-log
        inputDetail:
          plugin:
            inputs:
              -
                # The input type. 
                type: service_docker_stdout
                detail:
                  # Collect stdout and stderr streams. 
                  Stdout: true
                  Stderr: true
                  K8sNamespaceRegex: "^kube-system$"
                  K8sPodRegex: "^kube-flannel-ds.*$"
  • Example for collecting log files of the auto scaling plug-in:
    apiVersion: log.alibabacloud.com/v1alpha1
    kind: AliyunLogConfig
    metadata:
      # The name that you specify must be unique in the cluster. 
      name: k8s-cluster-autoscaler-log
      namespace: kube-system
    spec:
      # The name of the Logstore to which the log files are collected. 
      logstore: k8s-cluster-autoscaler-log
      # The detailed settings of the Logtail configuration. 
      logtailConfig:
        # The input type of Docker stdout is plugin. 
        inputType: plugin
        # The name of the Logtail configuration. The name must be the same as that specified by the metadata.name field. 
        configName: k8s-cluster-autoscaler-log
        inputDetail:
          plugin:
            inputs:
              -
                # The input type. 
                type: service_docker_stdout
                detail:
                  # Collect stdout and stderr streams. 
                  Stdout: true
                  Stderr: true
                  K8sNamespaceRegex: "^kube-system$"
                  K8sPodRegex: "^cluster-autoscaler.*$"

Step 2: View log files

For more information about how to view log files, see Step 4: View log files.