Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate different log aggregation/streaming approaches #91

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b09c605
Changes folder name for merge to 1.8 master
solsson Nov 4, 2017
d274f48
No reason to run in kube-system namespace
solsson Nov 4, 2017
975ac91
Manifest updated to k8s 1.8
solsson Nov 4, 2017
6a7ca44
Same level of producer info as in events-kube, and ...
solsson Nov 4, 2017
ebfbfc0
Fixes log reading in GKE's 1.8.1 nodes
solsson Nov 4, 2017
a6c522f
test stub
solsson Oct 10, 2017
a693a22
Prints only some logs to test log, to avoid an infinite loop of aggre…
solsson Oct 10, 2017
efa3676
Makes test printout compatible with jq
solsson Oct 11, 2017
0b0cbfd
Intuitively the exit condition should be last, I think
solsson Oct 11, 2017
0806ce0
Uses latest kafkacat build for logs test
solsson Nov 4, 2017
959d4c5
Refreshes test syntax from Yolean/kube-test
solsson Nov 4, 2017
eb2f895
Updates manifest to k8s 1.8
solsson Nov 4, 2017
e34628d
Merge branch 'logs-streaming-test' into 1.8-logs-streaming
solsson Nov 4, 2017
55e0e20
As in #60: Need >1 replicas for producer to handle pod rescheduling
solsson Nov 4, 2017
224cfbe
Can't output as JSON unless aggregation produces JSON
solsson Nov 4, 2017
9446d4a
Increases readability of test output
solsson Nov 4, 2017
0dcde3e
We'll lose some lines at restart, but we'll pick up new containers ...
solsson Nov 4, 2017
9166ebd
Got categorized as CrashLoopBackoff
solsson Nov 4, 2017
5d3fd7c
Leaves room for log collectors, now that I like this one ...
solsson Nov 4, 2017
986d10b
Rock solid :) ...
solsson Nov 4, 2017
da19538
Merge branch 'raw-restart-on-new-files' into 1.8-logs-streaming
solsson Nov 4, 2017
8528f0b
Beat this, fluent-bit :) ...
solsson Nov 4, 2017
68b829b
Moves "raw" to the logs-kafka namespace
solsson Nov 6, 2017
97f446d
Had problems with pods not terminating
solsson Nov 6, 2017
de0b1f5
Uses node name as key so we can preserver ordering
solsson Nov 6, 2017
cc99542
Latest https://github.com/edenhill/kafkacat/pull/123
solsson Nov 6, 2017
64ab61f
kafkacat based on same image as solsson/kafka:1.0.0
solsson Nov 7, 2017
17b7ccc
Kafkacat support for -k has been merged now
solsson Nov 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions addon-logs/logs-kube-kafka.yml

This file was deleted.

82 changes: 82 additions & 0 deletions logs-streaming/logs-kube-kafka-raw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apps/v1beta2
kind: DaemonSet
metadata:
name: logs-kafka-raw
namespace: logs-kafka
spec:
selector:
matchLabels:
k8s-app: logs-kafka
log-wrapping: none
container-delimiters: tail
version: v1
kubernetes.io/cluster-service: "true"
template:
metadata:
labels:
k8s-app: logs-kafka
log-wrapping: none
container-delimiters: tail
version: v1
kubernetes.io/cluster-service: "true"
spec:
# maybe the /bin/sh does not forward signals?
terminationGracePeriodSeconds: 5
containers:
- name: kafkacat
image: solsson/kafkacat@sha256:b32eedf936f3cde44cd164ddc77dfcf7565a8af4e357ff6de1abe4389ca530c9
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
command:
- sh
- -ec
- >
find /var/log/containers/ -maxdepth 1 -name *.log | grep -v "/$HOSTNAME" | tee /tmp/start-list;
cd /var/log/containers/;
tail
-n 0
--follow=name
*.log
|
kafkacat
-b kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
-t ops-kube-logs-raw-001
-P
-z snappy
-v
-d broker,topic
-k $NODE_NAME
livenessProbe:
exec:
command:
- /bin/sh
- -c
- find /var/log/containers/ -maxdepth 1 -name *.log | grep -v "/$HOSTNAME" | diff - /tmp/start-list
failureThreshold: 1
initialDelaySeconds: 5
periodSeconds: 5
resources:
requests:
cpu: 2m
memory: 4Mi
limits:
cpu: 10m
memory: 4Mi
volumeMounts:
- name: varlog
mountPath: /var/log
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 10
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
75 changes: 75 additions & 0 deletions logs-streaming/test/logs-raw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
kind: ConfigMap
metadata:
name: logs-raw
namespace: test-kafka
apiVersion: v1
data:

setup.sh: |-
touch /tmp/testlog

tail -f /tmp/testlog

test.sh: |-
exec >> /tmp/testlog
exec 2>&1

echo ""
echo "{\"#---\":\"$(date -u --iso-8601='ns')\"}"
kafkacat -b $BOOTSTRAP -C -t $TOPIC -f '\n%t@%p [%o] %k: %s\n' -o -10 -e

exit 0

quit-on-nonzero-exit.sh: |-
exit 0

---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: logs-raw
namespace: test-kafka
spec:
replicas: 1
selector:
matchLabels:
test-target: logs-streaming-raw
test-type: readiness
template:
metadata:
labels:
test-target: logs-streaming-raw
test-type: readiness
spec:
containers:
- name: testcase
image: solsson/kafkacat@sha256:ebebf47061300b14a4b4c2e1e4303ab29f65e4b95d34af1b14bb8f7ec6da7cef
env:
- name: BOOTSTRAP
value: kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
- name: TOPIC
value: ops-kube-logs-raw-001
command:
- /bin/bash
- -e
- /test/setup.sh
readinessProbe:
exec:
command:
- /bin/bash
- -e
- /test/test.sh
livenessProbe:
exec:
command:
- /bin/bash
- -e
- /test/quit-on-nonzero-exit.sh
volumeMounts:
- name: config
mountPath: /test
volumes:
- name: config
configMap:
name: logs-raw
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: batch/v1
kind: Job
metadata:
name: topic-ops-kube-logs-raw
namespace: kafka
namespace: logs-kafka
spec:
template:
metadata:
Expand All @@ -17,16 +17,15 @@ spec:
command:
- ./bin/kafka-topics.sh
- --zookeeper
- zookeeper:2181
- zookeeper.kafka:2181
- --create
- --if-not-exists
- --topic
- ops-kube-logs-raw-001
- --partitions
- "1"
- --replication-factor
- "1"
- "2"
- --config
# this might be eight days
- retention.ms=69125000
- retention.ms=6912500000
restartPolicy: Never
6 changes: 3 additions & 3 deletions test/basic-produce-consume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ data:

tail -f /tmp/testlog

continue.sh: |-
exit 0

run.sh: |-
exec >> /tmp/testlog
exec 2>&1
Expand All @@ -37,6 +34,9 @@ data:

exit 0

continue.sh: |-
exit 0

---
apiVersion: apps/v1beta1
kind: Deployment
Expand Down
6 changes: 3 additions & 3 deletions test/basic-with-kafkacat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ data:
touch /tmp/testlog
tail -f /tmp/testlog

continue.sh: |-
exit 0

run.sh: |-
exec >> /tmp/testlog
exec 2>&1
Expand All @@ -24,6 +21,9 @@ data:

exit 0

continue.sh: |-
exit 0

---
apiVersion: batch/v1
kind: Job
Expand Down