Skip to content

Commit

Permalink
updated README with a better example on how to extend this image
Browse files Browse the repository at this point in the history
  • Loading branch information
Arik Kfir committed Sep 23, 2017
1 parent e57b496 commit efea3c1
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,49 @@ to collect log files from its sibling containers.

## Usage

Here's an example Pod using this container:
Extend this image by creating your own image:

my-loggly-sidecar
|
+-- Dockerfile
|
+-- fluent.conf

Here's an example `Dockerfile`:

FROM infolinks/loggly-sidecar:v3
MAINTAINER Arik Kfir <arik@infolinks.com>

And here's an example `fluent.conf` file collecting `Apache` access logs:

<source>
@type tail
path /var/log/access_log
pos_file /var/log/access_log.pos
<parse>
@type apache2
</parse>
tag httpd.access_log
</source>

<match httpd.access_log>
@type loggly_buffered
loggly_url https://logs-01.loggly.com/bulk/#{ENV['LOGGLY_TOKEN']}/tag/httpd.access_log,httpd
buffer_type file
buffer_path /var/log/access_log.buffer
flush_interval 10s
</match>

Note how the loggly token is not embedded in the `fluentd.conf` file,
but taken from the environment variable `LOGGLY_TOKEN`, which will be
provided from the Kubernetes manifest below.

Build it using:

docker build -t my-loggly-sidecar .

And here's an example Kubernetes deployment manifest putting it all
together:

apiVersion: apps/v1beta1
kind: Deployment
Expand All @@ -20,46 +62,23 @@ Here's an example Pod using this container:
app: my-pod
spec:
containers:

# this container generates log files under "/var/log/my-pod":
- name: my-container1
image: my/container:latest
- name: httpd
image: httpd
volumeMounts:
- name: logs
mountPath: /var/log/my-pod

# this is the sidecar:
mountPath: /var/log/httpd
- name: loggly
image: infolinks/loggly-sidecar
image: my-loggly-sidecar
env:
- name: LOGGLY_TOKEN
value: <your_loggly_token_here>
volumeMounts:
- name: fluentd
mountPath: /fluentd/etc/conf.d
readOnly: true
- name: logs
mountPath: /var/log/my-pod

mountPath: /var/log/httpd
volumes:
# shared logs volume mounted by both containers - one writes
# logs into it, and the sidecar reads logs from it
- name: logs
emptyDir: {}

# volume mounted by the sidecar - this volume should contain
# fluentd configurations for reading the logs at /var/log/my-pod
# usually you would want this to be populated from a configmap
# so you could reconfigure fluentd, but you could use any
# technique you want, as long as the fluentd "conf" files
# are in this volume.
# alternatively, you could create your own Docker image that
# extends the "loggly-sidecar" image, and import your conf
# files to "/fluentd/etc/conf.d" yourself (in such a case,
# a volume mount is not necessary)
- name: fluentd
...

## Contributions

Any contribution to the project will be appreciated! Whether it's bug
Expand Down

0 comments on commit efea3c1

Please sign in to comment.