Skip to content

Commit 3dd95af

Browse files
committed
A decent devloop
Displaying unparsed log entries using kubectl apply -k base; kubectl rollout status daemonset fluent-bit; kubectl logs -f -l app.kubernetes.io/name=fluent-bit Issues like fluent#88 and fluent/fluent-bit#1902 (comment) indicate that depending on /var/log/containers symlinks cause quite a few issues. /var/log/pods/ is the path stated in https://github.com/kubernetes/kubernetes/blob/v1.22.0/pkg/kubelet/kuberuntime/kuberuntime_manager.go#L63 and I've verified on GKE cos-containerd, GKE ubuntu-dockerd and k3s that the path contains the actual files, not symliks. Also using /var/log/pods makes it trivial to exclude logs from any container named fluent-bit. Doing so reduces the risk of endless log loops.
1 parent f99ebff commit 3dd95af

File tree

7 files changed

+36
-25
lines changed

7 files changed

+36
-25
lines changed

base/filter-kubernetes.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Kube_URL https://kubernetes.default.svc:443
55
Kube_CA_File /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
66
Kube_Token_File /var/run/secrets/kubernetes.io/serviceaccount/token
7-
Kube_Tag_Prefix kube.var.log.containers.
7+
Kube_Tag_Prefix kube.var.log.pods.
88
Merge_Log On
99
Merge_Log_Key log_processed
1010
K8S-Logging.Parser On

base/fluent-bit-daemonset.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ spec:
2828
containers:
2929
- name: fluent-bit
3030
image: docker.io/fluent/fluent-bit
31+
env:
32+
- name: LOG_LEVEL
33+
value: debug
3134
ports:
3235
- name: http
3336
containerPort: 2020
@@ -40,20 +43,27 @@ spec:
4043
path: /api/v1/health
4144
port: http
4245
volumeMounts:
43-
- name: varlog
44-
mountPath: /var/log
45-
- name: varlibdockercontainers
46-
mountPath: /var/lib/docker/containers
46+
- name: varlogpods
47+
mountPath: /var/log/pods
4748
readOnly: true
49+
- name: db
50+
mountPath: /var/run/fluent-bit
4851
- name: config
4952
mountPath: /fluent-bit/etc/
53+
# - mountPath: /etc/machine-id
54+
# name: etcmachineid
55+
# readOnly: true
5056
volumes:
51-
- name: varlog
57+
- name: varlogpods
5258
hostPath:
53-
path: /var/log
54-
- name: varlibdockercontainers
59+
path: /var/log/pods
60+
- name: db
5561
hostPath:
56-
path: /var/lib/docker/containers
62+
path: /var/run/fluent-bit
63+
# - name: etcmachineid
64+
# hostPath:
65+
# path: /etc/machine-id
66+
# type: File
5767
- name: config
5868
configMap:
5969
name: fluent-bit

base/fluent-bit.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[SERVICE]
22
Flush 1
3-
Log_Level info
3+
Log_Level ${LOG_LEVEL}
44
Daemon off
55
Parsers_File parsers.conf
66
HTTP_Server On
77
HTTP_Listen 0.0.0.0
88
HTTP_Port 2020
99

1010
@INCLUDE input-kubernetes.conf
11-
@INCLUDE filter-kubernetes.conf
12-
@INCLUDE output-elasticsearch.conf
11+
#@INCLUDE filter-kubernetes.conf
12+
@INCLUDE outputs.conf

base/input-kubernetes.conf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[INPUT]
22
Name tail
33
Tag kube.*
4-
Path /var/log/containers/*.log
5-
Parser docker
6-
DB /var/log/flb_kube.db
4+
DB /var/run/fluent-bit/tail-positions.db
75
Mem_Buf_Limit 5MB
86
Skip_Long_Lines On
9-
Refresh_Interval 10
7+
DB.locking true
8+
Path /var/log/pods/*/*/*.log
9+
Exclude_Path /var/log/pods/*/fluent-bit/*.log
10+
#Parser cri

base/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ configMapGenerator:
2020
- fluent-bit.conf
2121
- input-kubernetes.conf
2222
- filter-kubernetes.conf
23-
- output-elasticsearch.conf
23+
- outputs.conf
2424
- parsers.conf

base/output-elasticsearch.conf

Lines changed: 0 additions & 8 deletions
This file was deleted.

base/outputs.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[OUTPUT]
2+
Name stdout
3+
Format json_lines
4+
json_date_key t
5+
json_date_format iso8601
6+
# Name file
7+
# Path /var/run/fluent-bit
8+
# File file-output.txt

0 commit comments

Comments
 (0)