When you run Kubernetes clusters outside of ACK—such as in an on-premises data center—you lose the built-in observability that managed clusters provide. Simple Log Service (SLS) fills this gap by giving you centralized log collection and analysis across all your registered clusters, regardless of where they run.
This topic walks you through three tasks: granting the Resource Access Management (RAM) permissions that the logtail-ds add-on requires, installing the add-on, and optionally configuring cluster-wide log collection rules.
Prerequisites
Before you begin, make sure you have:
-
An ACK One registered cluster with a self-managed Kubernetes cluster connected to it. See Create an ACK One registered cluster.
-
The cluster kubeconfig downloaded and kubectl connected to the registered cluster. See Obtain the cluster kubeconfig and connect to the registered cluster using kubectl.
Step 1: Configure RAM permissions for SLS components
The logtail-ds add-on needs RAM permissions to write logs to SLS. Two methods are available:
| Method | Best for |
|---|---|
| onectl (recommended) | Fastest path—a single command grants all required permissions automatically. |
| Console | Needed when you require fine-grained control over the RAM user and policy. |
Use onectl (recommended)
-
Install onectl on your on-premises machine. See Use onectl to manage registered clusters.
-
Grant RAM permissions for SLS components:
onectl ram-user grant --addon logtail-dsExpected output:
Ram policy ack-one-registered-cluster-policy-logtail-ds granted to ram user ack-one-user-ce313528c3 successfully.
Use the console
This method requires creating a RAM user, attaching a custom policy, and storing the credentials as a Kubernetes Secret.
-
Create a custom policy with the following content:
-
Create an AccessKey for the RAM user.
WarningConfigure a network policy to restrict AccessKey calls to trusted network environments. See AccessKey network access restriction policy.
-
Create a Secret named
alibaba-addon-secretin thekube-systemnamespace using the AccessKey from the previous step: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>'
Step 2: Install the logtail-ds component
Use onectl (recommended)
Install logtail-ds with a single command:
onectl addon install logtail-ds
Expected output:
Addon logtail-ds, version **** installed.
Use the console
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your registered cluster. In the left navigation pane, click Add-ons.
-
On the Add-ons page, click the Logs and Monitoring tab. Find logtail-ds and click Install in the lower-right corner of its card.
-
In the confirmation dialog box, click OK.
(Optional) Step 3: Configure log collection for all pods
Connect to the registered cluster via kubectl, then apply the configuration for the log type you need.
Text logs
Deploy the following AliyunLogConfig to collect text log files from all pods:
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: test-file # Must be unique in the cluster.
spec:
project: k8s-log-c326bc86**** # Optional. Recommended format: k8s-log-<cluster ID>.
logstore: test-file # Required. SLS creates this Logstore automatically if it does not exist.
logtailConfig:
inputType: file # "file" for text logs; "plugin" for standard output.
configName: test-file # Must match metadata.name.
inputDetail:
logType: common_reg_log # Collect text logs in simple mode.
logPath: /log/ # Directory where log files are located.
filePattern: "*.log" # Supports wildcard characters * and ?.
dockerFile: true # Set to true to collect files inside containers.
advanced: # Optional container filter conditions.
k8s:
K8sNamespaceRegex: ^(default)$
K8sPodRegex: '^(nginx-log-demo.*)$'
K8sContainerRegex: ^(nginx-log-demo-0)$
IncludeK8sLabel:
job-name: "^(nginx-log-demo.*)$"
For a full reference of Logtail configuration fields, see Logtail configurations (legacy).
Standard output
Deploy the following AliyunLogConfig to collect stdout and stderr from all containers. After a successful deployment, SLS automatically creates a Logstore named stdout-logstore and starts collecting logs into it.
All containers are included by default, except those with COLLECT_STDOUT_FLAG:false set in their Docker environment configuration.
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: stdout-collector # Must be unique in the cluster.
spec:
logstore: stdout-logstore # Logstore to upload logs to.
logtailConfig:
inputType: plugin # Use "plugin" for Docker stdout.
configName: stdout-collector # Must match metadata.name.
inputDetail:
plugin:
inputs:
- type: service_docker_stdout
detail:
Stdout: true
Stderr: true
# Collects all containers except those with "COLLECT_STDOUT_FLAG:false" in Docker env config.
Step 4: Configure Simple Log Service
With logtail-ds installed and log collection running, configure SLS to process and analyze the collected logs:
-
To configure SLS when creating a new application, see Configure Simple Log Service when creating an application.
-
To collect and analyze Nginx Ingress access logs, see Collect and analyze Nginx Ingress access logs.