Todos os produtos
Search
Central de documentação

Container Service for Kubernetes:Coletar logs de plugins do sistema

Última atualização: Aug 31, 2026

Os plugins do sistema (addons) usam recursos do Kubernetes, como DaemonSets e deployments, para fornecer funcionalidades de armazenamento e rede ao cluster. Esses recursos residem no namespace kube-system. Este tópico descreve como configure a coleta de logs dos principais plugins do sistema, incluindo os de armazenamento, rede e Auto Scaling.

Pré-requisitos

  • O log collection add-on está instalado.

    • Para Logtail: A versão do alibaba-log-controller deve ser 0.2.0.0-76648ee-aliyun ou superior.

      Se a versão do alibaba-log-controller estiver desatualizada, upgrade the Logtail add-on.

    • Para LoongCollector: Todas as versões são compatíveis.

  • O CoreDNS está atualizado para a versão mais recente. Consulte gerencie components.

Etapa 1: crie um arquivo de configuração de log para um plugin do sistema

A coleta de logs do ACK estende-se por meio de uma CustomResourceDefinition (CRD). Ao implantar uma configuração da CRD AliyunLogConfig, o Log Controller cria automaticamente as configurações de coleta e os recursos de relatório necessários para o Simple Log service. Para mais informações sobre como crie um recurso personalizado, consulte gerencie custom resources.

Use os exemplos a seguir para crie um arquivo de configuração AliyunLogConfig para os plugins de armazenamento, rede Terway, rede Flannel ou Auto Scaling.

  • Exemplo de configuração de log para o plugin de armazenamento CSI:

    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.*$"
  • Exemplo de configuração de log para o plugin de rede Terway:

    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.*$"
  • Exemplo de configuração de log para o plugin de rede Flannel:

    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.*$"
  • Exemplo de configuração de log para o plugin de Auto Scaling:

    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.*$"

Etapa 2: visualize logs

Para mais informações sobre como visualize logs, consulte Collect logs from containers in an ACK cluster.