我正在使用 Fluent-bit 版本 1.4.6,我正在尝试从 tomcat/logs 文件夹收集日志,但我收到:
[error] [input:tail:tail.0] read error, check permissions
日志文件夹中的这些文件都是“rw-r-----”(640)。
我尝试通过更改日志文件夹内文件的权限来确认它是否可以读取它,并且它可以工作,但这并不能解决总体问题。
我的问题是,这是否应该在 tomcat 级别设置,或者可以通过 Fluent-bit 完成?我可以以其他用户身份启动吗?
提前致谢!
您没有指定 👀 如何部署 fluence-bit。
但是,您可以以其他用户身份运行它,并在 Kubernetes 中指定 SecurityContext。
例如:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
k8s-app: fluent-bit-logging
template:
metadata:
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "2020"
prometheus.io/path: /api/v1/metrics/prometheus
spec:
securityContext:
runAsUser: 1000 👈 user id that you want to run the containers in the pod as
containers:
- name: fluent-bit
image: fluent/fluent-bit:1.3.11
imagePullPolicy: Always
ports:
- containerPort: 2020
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: fluent-bit-config
mountPath: /fluent-bit/etc/
- name: mnt
mountPath: /mnt
readOnly: true
...
✌️
需要做的是将 UMASK 设置为值为“111”的环境变量,这将更改日志文件的权限,以便它们可以被 Fluent-bit 获取。
这个umask 111应该应用在Dockerfile镜像端还是worker节点端?