Log Service allows you to collect and analyze logs from Kubernetes clusters deployed across different regions. This topic describes how to enable Log Service on an application that runs in an external Kubernetes cluster.

Prerequisites

You have connected to an external Kubernetes cluster through Container Service for Kubernetes. For more information, see Register a cluster.

Procedure

  1. Log on to the Container Service console.
  2. In the left-side navigation pane, choose Marketplace > App Catalog. The Alibaba Cloud Apps tab appears.
  3. Choose Operations/Observability (6) > ack-sls-log-controller.
    a
  4. Click the Parameters tab to set parameters.

    For more information about the parameters, see the Configuration section on the Description tab.

    Log Service parameters
    Note If a leased line connects the cluster and the VPC network, omit the -internet suffix from the value of parameter InstallParam and append the -intranet suffix to {region-id} of parameter Endpoint.
  5. In the Deploy section on the right, set the parameters and click Create.
    • Cluster: Select the cluster where the resource object is to be deployed.
    • Namespace: Select the namespace where the resource object belongs. The default namespace is default. Except for underlying compute resources such as nodes and PVs, most resources are scoped to namespaces.
    • Release Name: The release name of the resource object.

What to do next

After the application is created, you can run the following YAML file in the console to see whether Log Service is running normally.
apiVersion: v1
kind: Pod
metadata:
  name: my-demo
spec:
  containers:
  - name: my-demo-app
    image: 'registry.cn-hangzhou.aliyuncs.com/log-service/docker-log-test:latest'
    env:
    ######### Specify environment variables ###########
    - name: aliyun_logs_log-stdout
      value: stdout
    - name: aliyun_logs_log-varlog
      value: /var/log/*.log
    - name: aliyun_logs_mytag1_tags
      value: tag1=v1
    ###############################
    ######### Configure vulume mounting ###########
    volumeMounts:
    - name: volumn-sls-mydemo
      mountPath: /var/log
  volumes:
  - name: volumn-sls-mydemo
    emptyDir: {}
  ###############################
If you can find log data in Logstores log-stdou and log-varlog under the target project, it indicates that Log Service is running normally.
Note The display of log data may have latency.

If you have deployed Ingress-nginx in the cluster, see Analyze logs of Ingress to monitor access to Ingress.