This document describes how to collect logs from a Pod scheduled to a super node in a TKE cluster.
Collecting Logs to CLS
Authorizing a role to the service
Before collecting logs of a Pod on a super node to CLS, you need to authorize a role to the service to ensure that logs can be uploaded to CLS normally:
Follow the steps below:
1. Log in to CAM console > Role. 2. Click Create Role on the "Role" page.
3. In the Select role entity dialog box, click Tencent Cloud Product Service > TKE > TKE - EKS log collection, and click Next, as shown below:
4. Confirm role policy, and click Next.
5. Review role policy, and click Done to complete role configuration.
Configuring log collection
You need to enable TKE log collection feature and configure corresponding log collection rule when you finished service role authorization. For example, you need to specify workload collection and Pod labels collection. For more information, see Using CRD to Configure Log Collection via the Console. Collecting Logs to Kafka
To collect logs of a Pod on a super node to a self-built Kafka or CKafka cluster, you can configure the log collection rules in the console or CRD to define the collection source and consumer. After CRD configuration, the Pod collector will collect logs according to the configured rules.
The specific configuration of CRD is as follows:
apiVersion: cls.cloud.tencent.com/v1
kind: LogConfig
metadata:
name: test
spec:
kafkaDetail:
brokers: xxxxxx
topic: xxxxxx
messageKey:
valueFrom:
fieldRef:
fieldPath: metadata.name
timestampKey:
timestampFormat:
inputDetail:
type: container_stdout
containerStdout:
namespace: default
allContainers: false
container: xxx
includeLabels:
k8s-app: xxx
workloads:
- namespace: prod
name: sample-app
kind: deployment
container: xxx
containerFile:
namespace: default
container: xxx
includeLabels:
k8s-app: xxx
workload:
name: sample-app
kind: deployment
logPath: /opt/logs
filePattern: app_*.log
Was this page helpful?