-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
inject-secrets.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM debian:stretch-slim | ||
|
||
RUN apt-get update -y | ||
RUN apt-get install -y gettext | ||
|
||
COPY logger.sh / | ||
ENTRYPOINT ["/logger.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build: | ||
docker build . -t jvassev/animal-logger:latest | ||
|
||
push: build | ||
docker push jvassev/animal-logger:latest | ||
|
||
run: build | ||
docker run -ti --rm jvassev/animal-logger:latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: london | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: cat | ||
namespace: london | ||
labels: | ||
animal: cat | ||
breed: munchkin | ||
spec: | ||
containers: | ||
- image: jvassev/animal-logger | ||
imagePullPolicy: Always | ||
name: main | ||
env: | ||
- name: ANIMAL | ||
value: cat | ||
- name: SOUND | ||
value: meow | ||
volumes: | ||
- name: logs | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: paris | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: cat | ||
namespace: paris | ||
labels: | ||
animal: cat | ||
breed: sphynx | ||
spec: | ||
containers: | ||
- image: jvassev/animal-logger | ||
imagePullPolicy: Always | ||
name: main | ||
env: | ||
- name: ANIMAL | ||
value: cat | ||
- name: SOUND | ||
value: miaou | ||
volumes: | ||
- name: logs | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!./inject-secrets.sh | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: london | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: fluentd-config | ||
namespace: london | ||
data: | ||
fluent.conf: | | ||
<source> | ||
@type tail | ||
path /var/logs/dogd.log | ||
labels animal=dog, _container=main | ||
<parse> | ||
#@type json | ||
@type none | ||
</parse> | ||
</source> | ||
<match kube.paris.**> | ||
@type loggly | ||
loggly_url https://logs-01.loggly.com/inputs/$LOGGLY_TOKEN/tag/fluentd | ||
</match> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!./inject-secrets.sh | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: paris | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: fluentd-config | ||
namespace: paris | ||
data: | ||
fluent.conf: | | ||
<match **> | ||
@type loggly | ||
loggly_url https://logs-01.loggly.com/inputs/$LOGGLY_TOKEN/tag/fluentd | ||
</match> | ||
# <match **> | ||
# @type elasticsearch | ||
# include_tag_key false | ||
# host "cloud.humio.com" | ||
# path "/api/v1/dataspaces/sandbox/ingest/elasticsearch/" | ||
# scheme "https" | ||
# port "443" | ||
# user "$HUMIO_KEY" | ||
# password "" | ||
# logstash_format true | ||
# reload_connections "true" | ||
# logstash_prefix "fluentd:kubernetes2humio" | ||
# buffer_chunk_limit 1M | ||
# buffer_queue_limit 32 | ||
# flush_interval 1s | ||
# max_retry_wait 30 | ||
# disable_retry_limit | ||
# num_threads 8 | ||
# </match> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: london | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: dog | ||
namespace: london | ||
labels: | ||
animal: dog | ||
breed: pug | ||
spec: | ||
containers: | ||
- image: jvassev/animal-logger | ||
imagePullPolicy: Always | ||
name: main | ||
env: | ||
- name: ANIMAL | ||
value: dog | ||
- name: SOUND | ||
value: bark-bark | ||
- name: FILE | ||
value: /var/logs/dogd.log | ||
volumeMounts: | ||
- name: logs | ||
mountPath: /var/logs | ||
volumes: | ||
- name: logs | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: paris | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: dog | ||
namespace: paris | ||
labels: | ||
animal: dog | ||
breed: bulldog | ||
spec: | ||
containers: | ||
- image: jvassev/animal-logger | ||
imagePullPolicy: Always | ||
name: main | ||
env: | ||
- name: ANIMAL | ||
value: dog | ||
- name: SOUND | ||
value: ouah, ouah | ||
- name: FILE | ||
value: /var/logs/dogd.log | ||
volumeMounts: | ||
- name: logs | ||
mountPath: /var/logs | ||
volumes: | ||
- name: logs | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
ANIMAL="${ANIMAL:-some unknown animal}" | ||
SOUND="${SOUND:-???}" | ||
|
||
|
||
while true; do | ||
export now="$(date --rfc-3339=seconds)" | ||
export msg="I am $ANIMAL and I say '${SOUND}' #msgid$((var++))" | ||
export level="INFO" | ||
|
||
if [[ $(($RANDOM % 10)) == 0 ]]; then | ||
msg="Severe: $ANIMAL is unable to say '${SOUND}' #msgid$((var++))" | ||
level="ERROR" | ||
fi | ||
echo "$now [$level] $msg" | ||
|
||
if [[ "$FILE" != '' ]]; then | ||
echo '{ "timestamp": "$now", "level": "$level", "message": "$msg"}' | envsubst >> $FILE | ||
fi | ||
|
||
sleep 2 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# humio | ||
@type elasticsearch | ||
include_tag_key false | ||
host "cloud.humio.com" | ||
path "/api/v1/dataspaces/sandbox/ingest/elasticsearch/" | ||
scheme "https" | ||
port "443" | ||
user "$HUMIO_KEY" | ||
password "" | ||
logstash_format true | ||
reload_connections "true" | ||
logstash_prefix "fluentd:kubernetes2humio" | ||
buffer_chunk_limit 1M | ||
buffer_queue_limit 32 | ||
flush_interval 1s | ||
max_retry_wait 30 | ||
disable_retry_limit | ||
num_threads 8 | ||
|
||
|
||
|
||
# loggly | ||
@type loggly | ||
loggly_url https://logs-01.loggly.com/inputs/$LOGGLY_TOKEN/tag/fluentd | ||
|
||
|
||
|
||
# papetrail | ||
@type papertrail | ||
papertrail_host $PT_HOST | ||
papertrail_port $PT_PORT | ||
flush_interval 30 | ||
|
||
|
||
|
||
# clone | ||
<match $labels(animal=dog, breed=pug)> | ||
@type copy | ||
|
||
<store> | ||
</store> | ||
|
||
<store> | ||
</store> | ||
</match> | ||
|
||
|
||
|
||
# from file | ||
<source> | ||
@type mounted_file | ||
path /var/log/dogd.log | ||
labels animal=dog, _container=main | ||
<parse> | ||
@type none | ||
</parse> | ||
</source> | ||
|
||
|
||
|
||
|
||
# json | ||
<filter $labels(...)> | ||
@type parser | ||
format json | ||
key_name log | ||
reserve_data true | ||
suppress_parse_error_log true | ||
</filter> | ||
|
||
|
||
# show config | ||
POD=log-router-log-router-z64mc | ||
|
||
kubectl exec -n infra-system $POD -c reloader -- ls -l /fluentd/etc/ | ||
kubectl exec -n infra-system $POD -c reloader -- cat /fluentd/etc/ns-london.conf | ||
kubectl exec -n infra-system $POD -c reloader -- cat /fluentd/etc/ns-paris.conf | ||
kubectl exec -n infra-system $POD -c reloader -- cat /fluentd/etc/fluent.conf |