Skip to content

Instantly share code, notes, and snippets.

@binarylogic
Last active May 15, 2020 14:16
Show Gist options
  • Select an option

  • Save binarylogic/951ea32ed462933fa70c439f9cab06f3 to your computer and use it in GitHub Desktop.

Select an option

Save binarylogic/951ea32ed462933fa70c439f9cab06f3 to your computer and use it in GitHub Desktop.
Timber Fluentbit Kubernetes Configuration Files
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit-config
namespace: logging
labels:
k8s-app: fluent-bit
data:
fluent-bit.conf: |
[SERVICE]
Flush 1
Log_Level info
Daemon off
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
@INCLUDE input-kubernetes.conf
@INCLUDE filter-kubernetes.conf
@INCLUDE output-timber.conf
input-kubernetes.conf: |
[INPUT]
Name tail
Tag kube.*
Path /var/log/containers/*.log
Parser docker
DB /var/log/flb_kube.db
Mem_Buf_Limit 5MB
Skip_Long_Lines On
Refresh_Interval 10
filter-kubernetes.conf: |
[FILTER]
Name kubernetes
Match kube.*
Kube_URL https://kubernetes.default.svc.cluster.local:443
Merge_Log On
K8S-Logging.Parser On
output-timber.conf: |
[OUTPUT]
Name http
Match *
Host logs.timber.io
Port 443
URI /sources/${FLUENT_TIMBER_SOURCE_ID}/frames
Format msgpack
Header Authorization Bearer ${FLUENT_TIMBER_API_KEY}
Header Content-Type application/msgpack
tls On
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
template:
metadata:
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: fluent-bit
image: fluent/fluent-bit:0.14.9
imagePullPolicy: Always
ports:
- containerPort: 2020
env:
- name: FLUENT_TIMBER_API_KEY
value: "YOUR_API_KEY"
- name: FLUENT_TIMBER_SOURCE_ID
value: "YOUR_SOURCE_ID"
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
terminationGracePeriodSeconds: 10
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: fluent-bit-config
configMap:
name: fluent-bit-config
- name: mnt
hostPath:
path: /mnt
serviceAccountName: fluent-bit
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
@RuriRyan
Copy link

https://gist.github.com/binarylogic/951ea32ed462933fa70c439f9cab06f3#file-fluent-bit-configmap-yaml-L37
Is an interesting line. It can cause problems when the clusters domain is not cluster.local. As this is part of your official install guide I would recommend shortening it just to https://kubernetes.default.svc:443.

@binarylogic
Copy link
Author

Hey @RuriRyan, thanks for the tip. We've since moved away from Fluentbit in favor of Vector. I'd strongly recommend giving that a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment