Skip to content

Instantly share code, notes, and snippets.

@myclau
Created December 5, 2018 09:39
Show Gist options
  • Save myclau/63738017134f8392ed87b2fdeccf6ea6 to your computer and use it in GitHub Desktop.
Save myclau/63738017134f8392ed87b2fdeccf6ea6 to your computer and use it in GitHub Desktop.
fluentd-graylog-k8s
<match fluent.**>
@type null
</match>
<source>
@type tail
@id in_tail_container_logs
limit_recently_modified 1s
path /var/log/containers/*.log
pos_file /var/rancher-fluentd/db/fluentd-containers.log.pos
tag kubernetes.*
read_from_head true
<parse>
@type json
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
<filter kubernetes.**>
@type kubernetes_metadata
@id filter_kube_metadata
</filter>
<match **>
@type roundrobin
<store>
@type gelf
@log_level warn
include_tag_key true
buffer_chunk_limit 4096K
buffer_queue_limit 512
flush_interval 5s
max_retry_wait 30
disable_retry_limit
num_threads 8
host graylog01
port 12201
weight 60
</store>
<store>
@type gelf
@id out_graylog
@log_level warn
include_tag_key true
buffer_chunk_limit 4096K
buffer_queue_limit 512
flush_interval 5s
max_retry_wait 30
disable_retry_limit
num_threads 8
host graylog02
port 12201
weight 60
</store>
</match>
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluentd
namespace: rancher-logging
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: fluentd
namespace: rancher-logging
rules:
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: fluentd
roleRef:
kind: ClusterRole
name: fluentd
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: fluentd
namespace: rancher-logging
---
apiVersion: app/v1beta2
kind: DaemonSet
metadata:
name: fluentd
namespace: rancher-logging
labels:
k8s-app: fluentd-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
template:
metadata:
labels:
k8s-app: fluentd-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
serviceAccount: fluentd
serviceAccountName: fluentd
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- image: fluent/fluentd-kubernetes-daemonset:v0.12-debian-graylog
imagePullPolicy: Always
name: docker-log-fluentd
resources: {}
securityContext:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: false
stdin: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
tty: true
volumeMounts:
- mountPath: /var/log/containers
name: varlogcontainers
- mountPath: /var/lib/docker/containers
name: varlibdockercontainers
- mountPath: /d01/docker-data/containers
name: varlogd01
- mountPath: /var/rancher-fluentd/db/
name: positioningfile
- mountPath: /fluentd/etc/fluent.conf
name: fluent-conf
readOnly: true
subPath: fluent.conf
- mountPath: /var/log/pods
name: varlogpods
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: fluentd
serviceAccountName: fluentd
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /var/log/containers
type: ""
name: varlogcontainers
- hostPath:
path: /var/lib/docker/containers
type: ""
name: varlibdockercontainers
- hostPath:
path: /d01/docker-data/containers
type: ""
name: varlogd01
- hostPath:
path: /var/rancher-fluentd/db/
type: ""
name: positioningfile
- configMap:
defaultMode: 420
name: docker-log-conf
optional: false
name: fluent-conf
- hostPath:
path: /var/log/pods
type: ""
name: varlogpods
updateStrategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment