Skip to content

Instantly share code, notes, and snippets.

@Misterhex
Created June 11, 2018 00:26
Show Gist options
  • Save Misterhex/6836ac3fcef46cb580b48e6947f92106 to your computer and use it in GitHub Desktop.
Save Misterhex/6836ac3fcef46cb580b48e6947f92106 to your computer and use it in GitHub Desktop.
tail kubernetes events from metricbeat and fluentbit sidecar
---
apiVersion: v1
kind: ConfigMap
metadata:
name: metricbeat-config
namespace: beats
labels:
k8s-app: metricbeat
kubernetes.io/cluster-service: "true"
data:
metricbeat.yml: |-
metricbeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
output.file:
path: "/var/log/metricbeat"
filename: metricbeat-out
rotate_every_kb: 100000
permissions: 0777
---
apiVersion: v1
kind: ConfigMap
metadata:
name: metricbeat-daemonset-modules
namespace: beats
labels:
k8s-app: metricbeat
kubernetes.io/cluster-service: "true"
data:
kubernetes.yml: |-
- module: kubernetes
metricsets:
- event
period: 10s
hosts: ["localhost:10255"]
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentbit-cm
namespace: beats
data:
fluent-bit.conf: |-
[INPUT]
Name tail
Path /var/log/metricbeat/metricbeat-out
[OUTPUT]
Name stdout
Match *
---
apiVersion: v1
kind: ConfigMap
metadata:
name: metricbeat-config
namespace: beats
labels:
k8s-app: metricbeat
kubernetes.io/cluster-service: "true"
data:
metricbeat.yml: |-
metricbeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
output.file:
path: "/var/log/metricbeat"
filename: metricbeat-out
rotate_every_kb: 100000
permissions: 0777
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: metricbeat
namespace: beats
labels:
k8s-app: metricbeat
kubernetes.io/cluster-service: "true"
spec:
template:
metadata:
labels:
k8s-app: metricbeat
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: metricbeat
terminationGracePeriodSeconds: 30
hostNetwork: true
containers:
- name: metricbeat
image: docker.elastic.co/beats/metricbeat:6.2.4
args: [
"-c", "/etc/metricbeat.yml"
]
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
securityContext:
runAsUser: 0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: config
mountPath: /etc/metricbeat.yml
readOnly: true
subPath: metricbeat.yml
- name: modules
mountPath: /usr/share/metricbeat/modules.d
readOnly: true
- name: data
mountPath: /var/log/metricbeat
- name: fluentbit
image: fluent/fluent-bit
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: data
mountPath: /var/log/metricbeat
- name: fluentbit-cm
mountPath: /fluent-bit/etc
volumes:
- name: data
emptyDir: {}
- name: fluentbit-cm
configMap:
name: fluentbit-cm
- name: config
configMap:
defaultMode: 0600
name: metricbeat-config
- name: modules
configMap:
defaultMode: 0600
name: metricbeat-daemonset-modules
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: metricbeat
subjects:
- kind: ServiceAccount
name: metricbeat
namespace: beats
roleRef:
kind: ClusterRole
name: metricbeat
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: metricbeat
labels:
k8s-app: metricbeat
rules:
- apiGroups: [""] # "" indicates the core API group
resources:
- events
verbs:
- get
- watch
- list
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: metricbeat
namespace: beats
labels:
k8s-app: metricbeat
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment