19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14 ■ Configuring Logging

Starting Fluentd to Collect Logs

Having started the data source (the Kuebrnetes cluster application) and the backend database

(Elasticsearch), next we shall start the unifying layer between the two, Fluentd. Create a pod definition

file fluentd-es.yaml for Fluentd and copy the following listing to the definition file. The Docker image

fabric8/fluentd-kubernetes:v1.9 is used in the pod’s container. The Elasticsearch endpoint URL and

port to interface with are also specified. The pod mounts the system log directory /var/log and the Docker

containers directory /var/lib/docker/containers from the host path. Volumes of type hostPath are used.

A different log directory could also be mounted.

---

apiVersion: v1

kind: Pod

metadata:

name: fluentd-elasticsearch

spec:

containers:

-

env:

-

name: ELASTICSEARCH_HOST

value: "10.2.15.2"

-

name: ELASTICSEARCH_PORT

value: "9200"

image: "fabric8/fluentd-kubernetes:v1.9"

name: fluentd-elasticsearch

resources:

limits:

cpu: "0.1"

securityContext:

privileged: true

volumeMounts:

-

mountPath: /var/log

name: varlog

-

mountPath: /var/lib/docker/containers

name: varlibdockercontainers

readOnly: true

volumes:

-

hostPath:

path: /var/log

name: varlog

-

hostPath:

path: /var/lib/docker/containers

name: varlibdockercontainers

322

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!