Log Pilot日志采集
配置
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: log-pilot
labels:
k8s-app: log-pilot
namespace: default
spec:
selector:
matchLabels:
k8s-app: log-pilot
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
k8s-app: log-pilot
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: log-pilot
image: registry.cn-hangzhou.aliyuncs.com/acs/log-pilot:0.9.5-filebeat
env:
- name: "LOGGING_OUTPUT"
value: "logstash"
- name: "LOGSTASH_HOST"
value: "192.168.1.2"
- name: "LOGSTASH_PORT"
value: "5044"
- name: "LOGSTASH_LOADBALANCE"
value: "true"
- name: "NODE_NAME"
valueFrom:
fieldRef:
fieldPath: spec.nodeName
resources:
limits:
cpu: 1000m
memory: 1000Mi
requests:
cpu: 250m
memory: 128Mi
volumeMounts:
- name: sock
mountPath: /var/run/docker.sock
- name: logs
mountPath: /var/log/filebeat
- name: state
mountPath: /var/lib/filebeat
- name: root
mountPath: /host
readOnly: true
- name: localtime
mountPath: /etc/localtime
securityContext:
capabilities:
add:
- SYS_ADMIN
terminationGracePeriodSeconds: 30
volumes:
- name: sock
hostPath:
path: /var/run/docker.sock
- name: logs
hostPath:
path: /var/log/filebeat
- name: state
hostPath:
path: /var/lib/filebeat
- name: root
hostPath:
path: /
- name: localtime
hostPath:
path: /etc/localtime使用示例
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.kuboard.cn/layer: ''
k8s.kuboard.cn/name: nginx
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
k8s.kuboard.cn/layer: ''
k8s.kuboard.cn/name: nginx
spec:
containers:
- env:
# 采集pod内日志文件
- name: aliyun_logs_yace-nginx-error
value: /opt/log/*.log
# 采集k8s控制台输出日志
- name: aliyun_logs_yace-nginx-access
value: stdout
image: 'nginx:1.29.1-alpine'
imagePullPolicy: IfNotPresent
lifecycle: {}
name: nginx
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: 100m
memory: 100Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
# 采集pod内日志文件需要创建目录挂载
volumeMounts:
- mountPath: /opt/log
name: locallog
dnsConfig: {}
dnsPolicy: ClusterFirst
nodeSelector:
beta.kubernetes.io/arch: amd64
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
seLinuxOptions: {}
terminationGracePeriodSeconds: 30
# 采集pod内日志文件需要创建目录挂载
volumes:
- emptyDir: {}
name: locallog