Kubernetes Fluentd无法将日志写入/Fluentd/log目录

Kubernetes Fluentd无法将日志写入/Fluentd/log目录,kubernetes,fluentd,Kubernetes,Fluentd,我部署了一个fluentdsidecar容器,将我的应用程序放在一个pod中,从我的应用程序收集日志 这是我的侧车清单sidecar.yaml: spec: template: spec: containers: - name: fluentd image: fluent/fluentd ports: - containerPort: 24224 protocol: TCP

我部署了一个
fluentd
sidecar容器,将我的应用程序放在一个pod中,从我的应用程序收集日志

这是我的侧车清单
sidecar.yaml

spec:
  template:
    spec:
      containers:
        - name: fluentd
          image: fluent/fluentd
          ports:
          - containerPort: 24224
            protocol: TCP
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 100m
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 200Mi
          terminationMessagePath: /dev/termination-log
          volumeMounts:
          - mountPath: /etc/td-agent/config.d
            name: configmap-sidecar-volume
          securityContext:
            runAsUser: 101
            runAsGroup: 101
我使用此清单,并使用以下命令将其修补到部署中:

kubectl patch deployment my-deployment --patch “$(cat sidecar.yaml)”
部署已成功更新,但my fluentd容器似乎无法启动,并引发以下错误:

2020-10-16 09:07:07 +0000 [info]: parsing config file is succeeded path="/fluentd/etc/fluent.conf"
2020-10-16 09:07:08 +0000 [info]: gem 'fluentd' version '1.11.2'
2020-10-16 09:07:08 +0000 [warn]: [output_docker1] 'time_format' specified without 'time_key', will be ignored
2020-10-16 09:07:08 +0000 [error]: config error file="/fluentd/etc/fluent.conf" error_class=Fluent::ConfigError error="out_file: `/fluentd/log/docker.20201016.log` is not writable"
这是我的
fluent.conf
文件:

<source>
  @type forward
  bind 127.0.0.1
  port 24224
  <parse>
    @type json
  </parse>
</source>

@打字前进
绑定127.0.0.1
端口24224
@类型json

导致此问题的原因是什么?

fluentd的UID默认值为
1000
,除非通过env
FLUENT\u UID更改

/fluentd/log/docker.20201016.log不可写
-错误说明您的用户
101
没有对日志文件的写入权限。将安全上下文更改为
1000
或设置env
FLUENT\u UID=101
以解决问题

spec:
模板:
规格:
容器:
-姓名:fluentd
图片:fluent/fluentd
端口:
-集装箱港口:24224
协议:TCP
imagePullPolicy:如果不存在
资源:
限制:
中央处理器:100米
内存:200Mi
请求:
中央处理器:100米
内存:200Mi
terminationMessagePath:/dev/终止日志
体积数量:
-mountPath:/etc/td-agent/config.d
名称:configmap侧车卷
securityContext:
runAsUser:1000
runAsGroup:1000
相关资源:


我尝试了这两种方法,但看起来容器运行了几秒钟,然后再次进入CrashLoopBackOff状态。@bakadevops仍然存在相同的错误或其他错误?这很奇怪,但在我将图像从
fluent/fluentd
更改为
fluent/fluentd:v0.12.34
@bakadevops后,错误就消失了提到图像标签,它使用最新版本(
fluentd:latest
)。令人惊讶的是,它在过去两年里没有更新。我知道。然而,我认为最新版本会起作用。