cleanup.policy
参数需选择 delete,选择 compact 会导致 CLS 无法上报到 Kafka 而造成数据丢失。如下图所示:
apiVersion: apps/v1beta2kind: Deploymentmetadata:annotations:deployment.kubernetes.io/revision: "1"labels:k8s-app: kafkaqcloud-app: kafkaname: kafkanamespace: defaultspec:replicas: 1selector:matchLabels:k8s-app: kafkaqcloud-app: kafkatemplate:metadata:annotations:eks.tke.cloud.tencent.com/cpu: "0.25"eks.tke.cloud.tencent.com/mem: "0.5Gi"labels:k8s-app: kafkaqcloud-app: kafkaspec:containers:- env:- name: EKS_LOGS_OUTPUT_TYPEvalue: kafka- name: EKS_LOGS_KAFKA_BROKERSvalue: 10.0.16.42:9092- name: EKS_LOGS_KAFKA_TOPICvalue: eks- name: EKS_LOGS_KAFKA_MESSAGE_KEYvalueFrom:fieldRef:fieldPath: metadata.name- name: EKS_LOGS_METADATA_ONvalue: "true"- name: EKS_LOGS_LOG_PATHSvalue: stdout,/tmp/busy*.logimage: busybox:latestcommand: ["/bin/sh"]args: ["-c", "while true; do echo hello world; date; echo hello >> /tmp/busy.log; sleep 1; done"]imagePullPolicy: Alwaysname: whileresources:requests:cpu: 250mmemory: 512Mi
字段名 | 含义 |
EKS_LOGS_OUTPUT_TYPE | 消费端支持 kafka 和 cls,根据该 key 判断是否启用日志收集。 |
EKS_LOGS_LOG_PATHS | 日志路径,支持 stdout(表示采集标准输出)和绝对路径,支持 * 通配,多个路径用“,”分隔。 |
EKS_LOGS_METADATA_ON | 支持 true 或 false。不填写则默认为 true。 |
EKS_LOGS_KAFKA_TOPIC | 日志主题。 |
EKS_LOGS_KAFKA_BROKERS | kafka brokers,ip1:port1,ip1:port2,ip2:port2格式,多个用“,”分隔。对外用此环境变量,EKS_LOGS_KAFKA_HOST 以后不再对外可见。 |
EKS_LOGS_KAFKA_MESSAGE_KEY | 非必填。支持指定一个 key,将日志投递到指定分区。 对于未开启按 key 投递,日志将随机投递到不同分区里。 开启按 key 投递,带有同样 key 的日志,将投递到相同的分区里。 |
$ echo -n 'secretid' | base64c2VjcmV0aWQ=$ echo -n 'secretkey' | base64c2VjcmV0a2V5
apiVersion: v1kind: Secretmetadata:name: secretidkeydata:secretid: ""secretkey: ""
apiVersion: apps/v1beta2kind: Deploymentmetadata:annotations:deployment.kubernetes.io/revision: "1"labels:k8s-app: clsqcloud-app: clsname: clsnamespace: defaultspec:replicas: 1selector:matchLabels:k8s-app: clsqcloud-app: clstemplate:metadata:annotations:eks.tke.cloud.tencent.com/cpu: "0.25"eks.tke.cloud.tencent.com/mem: "0.5Gi"labels:k8s-app: clsqcloud-app: clsspec:containers:- env:- name: EKS_LOGS_OUTPUT_TYPEvalue: cls- name: EKS_LOGS_LOGSET_NAMEvalue: eks- name: EKS_LOGS_TOPIC_IDvalue: 617c8270-e8c8-46e2-a90b-d94c4bebe519- name: EKS_LOGS_SECRET_IDvalueFrom:secretKeyRef:name: secretidkeykey: secretid- name: EKS_LOGS_SECRET_KEYvalueFrom:secretKeyRef:name: secretidkeykey: secretkey- name: EKS_LOGS_LOG_PATHSvalue: stdout,/tmp/busy*.log- name: EKS_LOGS_METADATA_ONvalue: "true"image: busybox:latestcommand: ["/bin/sh"]args: ["-c", "while true; do echo hello world; date; echo hello >> /tmp/busy.log; sleep 1; done"]imagePullPolicy: Alwaysname: hello- env:- name: EKS_LOGS_OUTPUT_TYPEvalue: cls- name: EKS_LOGS_LOGSET_NAMEvalue: eks- name: EKS_LOGS_TOPIC_IDvalue: 617c8270-e8c8-46e2-a90b-d94c4bebe519- name: EKS_LOGS_SECRET_IDvalueFrom:secretKeyRef:name: secretidkeykey: secretid- name: EKS_LOGS_SECRET_KEYvalueFrom:secretKeyRef:name: secretidkeykey: secretkey- name: EKS_LOGS_LOG_PATHSvalue: stdout,/tmp/busy*.log- name: EKS_LOGS_METADATA_ONvalue: "true"image: busybox:latestcommand: ["/bin/sh"]args: ["-c", "while true; do echo hello world; date; echo hello >> /tmp/busy.log; sleep 1; done"]imagePullPolicy: Alwaysname: world
字段名 | 含义 |
EKS_LOGS_OUTPUT_TYPE | 消费端支持 kafka 和 cls,根据该 key 判断是否启用日志收集。 |
EKS_LOGS_LOG_PATHS | 日志路径,支持 stdout(表示采集标准输出)和绝对路径,支持 * 通配,多个路径用“,”分隔。 |
EKS_LOGS_METADATA_ON | 支持 true 或 false。不填写则默认为 true。 |
EKS_LOGS_LOGSET_NAME | CLS 日志集名称。 |
EKS_LOGS_TOPIC_ID | CLS 日志集的主题 ID。 |
EKS_LOGS_SECRET_ID | SecretId。 |
EKS_LOGS_SECRET_KEY | SecretKey。 |
template:metadata:annotations:eks.tke.cloud.tencent.com/role-name: "eks-pushlog"
apiVersion: apps/v1beta2kind: Deploymentmetadata:annotations:deployment.kubernetes.io/revision: "1"labels:k8s-app: clsqcloud-app: clsname: clsnamespace: defaultspec:replicas: 1selector:matchLabels:k8s-app: clsqcloud-app: clstemplate:metadata:annotations:eks.tke.cloud.tencent.com/cpu: "0.25"eks.tke.cloud.tencent.com/mem: "0.5Gi"eks.tke.cloud.tencent.com/role-name: "eks-pushlog"labels:k8s-app: clsqcloud-app: clsspec:containers:- env:- name: EKS_LOGS_OUTPUT_TYPEvalue: cls- name: EKS_LOGS_LOGSET_NAMEvalue: eks- name: EKS_LOGS_TOPIC_IDvalue: 617c8270-e8c8-46e2-a90b-d94c4bebe519- name: EKS_LOGS_LOG_PATHSvalue: stdout,/tmp/busy*.log- name: EKS_LOGS_METADATA_ONvalue: "true"image: busybox:latestcommand: ["/bin/sh"]args: ["-c", "while true; do echo hello world; date; echo hello >> /tmp/busy.log; sleep 1; done"]imagePullPolicy: Alwaysname: hello- env:- name: EKS_LOGS_OUTPUT_TYPEvalue: cls- name: EKS_LOGS_LOGSET_NAMEvalue: eks- name: EKS_LOGS_TOPIC_IDvalue: 617c8270-e8c8-46e2-a90b-d94c4bebe519- name: EKS_LOGS_LOG_PATHSvalue: stdout,/tmp/busy*.log- name: EKS_LOGS_METADATA_ONvalue: "true"image: busybox:latestcommand: ["/bin/sh"]args: ["-c", "while true; do echo hello world; date; echo hello >> /tmp/busy.log; sleep 1; done"]imagePullPolicy: Alwaysname: world
字段名 | 含义 |
EKS_LOGS_OUTPUT_TYPE | 消费端支持 kafka 和 cls,根据该 key 判断是否启用日志收集。 |
EKS_LOGS_LOG_PATHS | 日志路径,支持 stdout(表示采集标准输出)和绝对路径,支持 * 通配,多个路径用“,”分隔。 |
EKS_LOGS_METADATA_ON | 支持 true 或 false。不填写则默认为 true。 |
EKS_LOGS_LOGSET_NAME | CLS 日志集名称。 |
EKS_LOGS_TOPIC_ID | CLS 日志集的主题 ID。 |
本页内容是否解决了您的问题?