首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fluentd未从ConfigMap加载配置

Fluentd未从ConfigMap加载配置
EN

Stack Overflow用户
提问于 2019-06-08 19:10:50
回答 1查看 546关注 0票数 2

我使用Fluentd作为侧车,将nginx日志发送到stdout,以便它们显示在Pod的日志中。我有一个奇怪的问题,当容器启动时Fluentd没有选择配置。

在检查Fluentd启动日志时,似乎没有加载配置。容器启动时,应该从/etc/fluentd- config /fluentd.conf加载配置。我已经连接到容器,配置文件是正确的,pv安装也是正确的。环境变量也存在。

完整的部署规范在下面--如果你想使用它,它是自包含的。

代码语言:javascript
复制
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: weblog-pv
    labels:
      type: local
  spec:
    storageClassName: manual
    accessModes: 
    - ReadWriteOnce
    hostPath:
      path: /tmp/weblog
      type: DirectoryOrCreate
    capacity: 
      storage: 500Mi

- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: weblog-pvc
  spec:
    storageClassName: manual
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 200Mi

- apiVersion: v1
  kind: ConfigMap
  metadata:
    name: fluentd-config
  data:
    fluentd.conf: |
      <source>
        @type tail
        format none
        path /var/log/nginx/access.log
        tag count.format1
      </source>
      <match *.**>
        @type forward
        <server>
          name localhost
          host 127.0.0.1
        </server>
      </match>

- apiVersion: v1
  kind: Pod
  metadata:
    name: sidecar-example
    labels:
      app: webserver
  spec:
    containers:
    - name: nginx
      image: nginx:latest
      ports: 
      - containerPort: 80
      volumeMounts:
      - name: logging-vol
        mountPath: /var/log/nginx
    - name: fdlogger
      env:
        - name: FLUENTD_ARGS
          value: -c /etc/fluentd-config/fluentd.conf
      image: fluent/fluentd
      volumeMounts:
      - name: logging-vol
        mountPath: /var/log/nginx
      - name: log-config
        mountPath: /etc/fluentd-config
    volumes:
      - name: logging-vol
        persistentVolumeClaim: 
          claimName: weblog-pvc
      - name: log-config
        configMap:
          name: fluentd-config

- apiVersion: v1
  kind: Service
  metadata:
    name: sidecar-svc
  spec:
    selector:
      app:  webserver
    type: NodePort
    ports:
    - name:  sidecar-port
      port:  80
      nodePort:  32000
EN

回答 1

Stack Overflow用户

发布于 2019-06-08 19:59:01

我通过使用stdout而不是重定向到localhost来让它工作。

代码语言:javascript
复制
- apiVersion: v1
  kind: ConfigMap
  metadata:
    name: fluentd-config
  data:
    fluent.conf: |
      <source>
        @type tail
        format none
        path /var/log/nginx/access.log
        tag count.format1
      </source>
      <match *.**>
        @type stdout
      </match>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56505798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档