elasticio/fluentd-kubernetes-gelfFluentd Kubernetes Gelf镜像专为Kubernetes环境设计,集成Fluentd日志收集工具与GELF(Graylog Extended Log Format)输出功能,提供容器化的日志收集解决方案。该镜像能够无缝对接Kubernetes集群,收集节点及Pod日志并转换为GELF格式,便于与Graylog等日志聚合系统集成,实现集群日志的集中收集、处理与分析。
bashdocker run -d --name fluentd-k8s-gelf \ --restart always \ -e GELF_HOST=graylog.example.com \ # GELF目标服务器地址(必填) -e GELF_PORT=*** \ # GELF目标服务器端口(默认***) -e KUBELET_URL=[***] \ # Kubelet API地址(用于获取容器元数据) -e LOG_LEVEL=info \ # 日志级别(debug/info/warn/error,默认info) -v /var/log:/var/log:ro \ # 挂载节点日志目录(只读) -v /var/lib/docker/containers:/var/lib/docker/containers:ro \ # 挂载容器日志目录(只读) -v /etc/kubernetes/pki:/etc/kubernetes/pki:ro \ # 挂载Kubernetes证书(如需访问API Server) fluentd-kubernetes-gelf:latest
| 参数名 | 描述 | 默认值 | 是否必填 |
|---|---|---|---|
GELF_HOST | GELF目标服务器IP或域名 | - | 是 |
GELF_PORT | GELF目标服务器端口 | *** | 否 |
GELF_PROTOCOL | GELF传输协议(udp/tcp/http) | udp | 否 |
KUBELET_URL | Kubelet API地址(用于获取容器元数据) | http://localhost:*** | 否 |
KUBERNETES_API_URL | Kubernetes API Server地址 | [***] | 否 |
LOG_LEVEL | Fluentd日志级别 | info | 否 |
BUFFER_SIZE_LIMIT | 日志缓冲区大小限制 | 10MB | 否 |
TAIL_PATH | 日志文件路径模板 | /var/log/containers/*.log | 否 |
yamlapiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-k8s-gelf namespace: kube-system labels: app: fluentd-k8s-gelf spec: selector: matchLabels: app: fluentd-k8s-gelf template: metadata: labels: app: fluentd-k8s-gelf spec: tolerations: - key: node-role.kubernetes.io/master effect: NoSchedule containers: - name: fluentd-k8s-gelf image: fluentd-kubernetes-gelf:latest resources: limits: memory: 512Mi requests: cpu: 100m memory: 200Mi env: - name: GELF_HOST value: "graylog.internal" # 替换为实际GELF服务器地址 - name: GELF_PORT value: "***" - name: LOG_LEVEL value: "info" volumeMounts: - name: varlog mountPath: /var/log readOnly: true - name: varlibdockercontainers mountPath: /var/lib/docker/containers readOnly: true - name: etckubernetes mountPath: /etc/kubernetes/pki readOnly: true - name: runlogjournal mountPath: /run/log/journal readOnly: true volumes: - name: varlog hostPath: path: /var/log - name: varlibdockercontainers hostPath: path: /var/lib/docker/containers - name: etckubernetes hostPath: path: /etc/kubernetes/pki - name: runlogjournal hostPath: path: /run/log/journal
通过挂载Fluentd配置文件(fluent.conf)可实现高级日志处理需求,示例配置片段:
xml# 从容器日志文件收集日志 <source> @type tail path "#{ENV['TAIL_PATH']}" pos_file /var/log/fluentd-containers.log.pos tag kube.* format json time_key time time_format %Y-%m-%dT%H:%M:%S.%NZ read_from_head true </source> # 过滤并增强Kubernetes元数据 <filter kube.**> @type kubernetes_metadata kube_url "#{ENV['KUBERNETES_API_URL']}" verify_ssl true ca_file /etc/kubernetes/pki/ca.crt </filter> # 输出至GELF目标 <match **> @type gelf host "#{ENV['GELF_HOST']}" port "#{ENV['GELF_PORT']}" protocol "#{ENV['GELF_PROTOCOL']}" include_tag_key true tag_key tag flush_interval 5s buffer_chunk_limit "#{ENV['BUFFER_SIZE_LIMIT']}" </match>
自定义配置文件可通过-v /path/to/custom/fluent.conf:/fluentd/etc/fluent.conf挂载至容器。



manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务