How to enable logging for third party containers in Kubernetes?

2/18/2019

The similar as Docker using this as below to configure logging in compose file for third party (mariadb, opentsdb ...) to show logs on Kibana.

logging:
            driver: fluentd
            options:
                fluentd-address: "0.0.0.0:24224"
                tag: "docker.{{.ID}}"

I want to ask that how to configure for Kubernetes?

-- Ken Kul
kubernetes

1 Answer

2/20/2019

Basically, you can use fluentd to collect logs and push them to 3rd party log storage (StackDriver or ElasticSearch). To ensure that fluentd is running on every cluster node we can use DaemonSet object.

As an example let’s see a part of the file content:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: kube-system
  ...
spec:
    ...
    spec:
      containers:
      - name: fluentd
        image: quay.io/fluent/fluentd-kubernetes-daemonset
        env:
          - name:  FLUENT_ELASTICSEARCH_HOST
            value: "elasticsearch-logging"
          - name:  FLUENT_ELASTICSEARCH_PORT
            value: "9200"
        ...

This article describes most important steps to get everything set up.

Get Fluentd DaemonSet sources

We have created a Fluentd DaemonSet that have the proper rules and container image ready to get started:

https://github.com/fluent/fluentd-kubernetes-daemonset

Please grab a copy of the repository from the command line using GIT:

$ git clone https://github.com/fluent/fluentd-kubernetes-daemonset
-- VAS
Source: StackOverflow