Todos os produtos
Search
Central de documentação

Container Service for Kubernetes:Integre o Simple Log Service a um cluster registrado

Última atualização: Sep 29, 2026

Integrar um cluster registrado ao Simple Log Service proporciona uma forma unificada de gerenciar clusters Kubernetes distribuídos em diferentes ambientes. Este tópico descreve como integrar o Simple Log Service a um cluster registrado por meio de um aplicativo no Container Service for Kubernetes (ACK).

Pré-requisitos

Etapa 1: Configure as permissões de RAM

Use o onectl

  1. Instale e configure o onectl em sua máquina local. Para obter mais informações, consulte Manage registered clusters using onectl.

  2. Execute o comando a seguir para configurar as permissões de RAM para o componente Simple Log Service:

    onectl ram-user grant --addon logtail-ds

    Saída esperada:

    Ram policy ack-one-registered-cluster-policy-logtail-ds granted to ram user ack-one-user-ce313528c3 successfully.

Use o console

Antes de instalar componentes em um cluster registrado, crie um par de AccessKey para conceder ao cluster permissões de acesso aos serviços de cloud. Para isso, crie um usuário RAM e conceda as permissões necessárias.

  1. Create a RAM user.

  2. Create a custom policy. Utilize o conteúdo de política a seguir.

    Show sample code

    {
        "Version": "1",
        "Statement": [
            {
                "Action": [
                    "log:CreateProject",
                    "log:GetProject",
                    "log:DeleteProject",
                    "log:CreateLogStore",
                    "log:GetLogStore",
                    "log:UpdateLogStore",
                    "log:DeleteLogStore",
                    "log:CreateConfig",
                    "log:UpdateConfig",
                    "log:GetConfig",
                    "log:DeleteConfig",
                    "log:CreateMachineGroup",
                    "log:UpdateMachineGroup",
                    "log:GetMachineGroup",
                    "log:DeleteMachineGroup",
                    "log:ApplyConfigToGroup",
                    "log:GetAppliedMachineGroups",
                    "log:GetAppliedConfigs",
                    "log:RemoveConfigFromMachineGroup",
                    "log:CreateIndex",
                    "log:GetIndex",
                    "log:UpdateIndex",
                    "log:DeleteIndex",
                    "log:CreateSavedSearch",
                    "log:GetSavedSearch",
                    "log:UpdateSavedSearch",
                    "log:DeleteSavedSearch",
                    "log:CreateDashboard",
                    "log:GetDashboard",
                    "log:UpdateDashboard",
                    "log:DeleteDashboard",
                    "log:CreateJob",
                    "log:GetJob",
                    "log:DeleteJob",
                    "log:UpdateJob",
                    "log:PostLogStoreLogs",
                    "log:CreateSortedSubStore",
                    "log:GetSortedSubStore",
                    "log:ListSortedSubStore",
                    "log:UpdateSortedSubStore",
                    "log:DeleteSortedSubStore",
                    "log:CreateApp",
                    "log:UpdateApp",
                    "log:GetApp",
                    "log:DeleteApp",
                    "cs:DescribeTemplates",
                    "cs:DescribeTemplateAttribute"
                ],
                "Resource": [
                    "*"
                ],
                "Effect": "Allow"
            }
        ]
    }
  3. Attach the policy to the RAM user.

  4. Create an AccessKey para o usuário RAM.

    Aviso

    Para aumentar a segurança, configure uma política de controle de acesso à rede para o AccessKey e restrinja o acesso a ambientes de rede confiáveis. Para obter mais informações, consulte AccessKey-based network access restriction policies.

  5. Use o par de AccessKey para criar um Secret chamado alibaba-addon-secret no cluster registrado.

    Execute o comando a seguir para criar o Secret usado pelo componente Logtail.

    kubectl -n kube-system create secret generic alibaba-addon-secret --from-literal='access-key-id=<your AccessKey ID>' --from-literal='access-key-secret=<your AccessKey Secret>'
    Nota

    Substitua <your AccessKey ID> e <your AccessKey Secret> pelos valores do seu par de AccessKey.

Etapa 2: Instale o componente logtail-ds

Use o onectl

Execute o comando a seguir para instalar o componente logtail-ds:

onectl addon install logtail-ds

Saída esperada:

Addon logtail-ds, version **** installed.

Use o console

  1. Acesse o ACK console. No painel de navegação à esquerda, clique em Clusters.

  2. Na página Clusters, clique no nome do cluster desejado. No painel de navegação à esquerda, clique em Add-ons.

  3. Na página Add-ons, clique na guia Logs and Monitoring. Encontre o componente logtail-ds e clique em Install no canto inferior direito do cartão.

  4. Na caixa de diálogo Note, clique em OK.

(Opcional) Etapa 3: Configure a coleta de logs dos pods

Logs de texto

Para coletar logs de texto dos pods, conecte-se ao cluster registrado usando kubectl e aplique a seguinte configuração do AliyunLogConfig.

apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: test-file                  # The name of the resource. The name must be unique in the Kubernetes cluster.
spec:
  project: k8s-log-c326bc86****    # Optional. The name of the project. You can customize the name. We recommend that you name the project in the k8s-log-<cluster-id> format.
  logstore: test-file              # Required. The name of the Logstore. If the specified Logstore does not exist, Simple Log Service automatically creates it.
  logtailConfig:                   # The Logtail configuration.
    inputType: file                # The type of the data source. Set the value to file for text logs or plugin for stdout.
    configName: test-file          # The name of the Logtail configuration. The name must be the same as the resource name specified by metadata.name.
    inputDetail:                   # The details of the Logtail configuration.
      logType: common_reg_log      # Collects text logs in simple mode.
      logPath: /log/               # The path where the log files are stored.
      filePattern: "*.log"         # The name of the log file. You can use asterisks (*) and question marks (?) as wildcards. Example: log_*.log.
      dockerFile: true             # Specifies whether to collect logs from files in containers. Set the value to true.
      advanced:                    # Specifies the conditions to filter containers.
        k8s:
          K8sNamespaceRegex: ^(default)$
          K8sPodRegex: '^(nginx-log-demo.*)$'
          K8sContainerRegex: ^(nginx-log-demo-0)$
          IncludeK8sLabel:
            job-name: "^(nginx-log-demo.*)$"

Para obter mais informações sobre os parâmetros, consulte Logtail configurations (Legacy).

Stdout

Para coletar o stdout dos pods, conecte-se ao cluster registrado usando kubectl e aplique a seguinte configuração do AliyunLogConfig. Essa configuração cria automaticamente um Logstore chamado stdout-logstore e coleta os logs nele.

apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  # The name of your configuration. The name must be unique in your Kubernetes cluster.
  name: stdout-collector
spec:
  # The name of the Logstore to which logs are uploaded.
  logstore: stdout-logstore
  # The details of the Logtail configuration.
  logtailConfig:
    # The input type for Docker stdout. Must be 'plugin'.
    inputType: plugin
    # The name of the Logtail configuration. Must match metadata.name.
    configName: stdout-collector
    inputDetail:
      plugin:
        inputs:
          -
            type: service_docker_stdout
            detail:
              # Collects stdout and stderr.
              Stdout: true
              Stderr: true
              # Collects the stdout of all containers except for those with the COLLECT_STDOUT_FLAG:false environment variable.

Etapa 4: Configure o Simple Log Service