kubernetes/cluster/addons/fluentd-elasticsearch
Kubernetes Submit Queue f5c29f51fa
Merge pull request #55506 from Random-Liu/fix-cri-fluentd
Automatic merge from submit-queue (batch tested with PRs 54460, 55258, 54858, 55506, 55510). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix CRI fluentd config.

This should fix the cri-containerd stackdriver test failure:
```
Cluster level logging implemented by Stackdriver should ingest logs
```

I copied the pattern from a comment previously. However, it doesn't actually work properly. `\b` only matches word boundary, and seems to match the boundary of previous word in our case.

That's why we get the log with a leading space:
```
Nov 10 18:39:11.661: INFO: Unexpected error occurred: log entry ingested incorrectly, got --> <--I0101 00:00:00.000000       1 main.go:1] Text, want Text
```

@kubernetes/sig-node-bugs @kubernetes/sig-instrumentation-bugs 

Signed-off-by: Lantao Liu <lantaol@google.com>

```release-note
none
```
2017-11-11 10:45:27 -08:00
..
es-image Merge pull request #54215 from mrahbar/elasticsearch_logging_discovery 2017-11-10 14:51:33 -08:00
fluentd-es-image Add CRI log format support in fluentd. 2017-10-30 06:25:52 +00:00
es-service.yaml Adds the new addon-manager labels on cluster addon templates 2017-02-24 16:53:12 -08:00
es-statefulset.yaml fluentd-elasticsearch add-on: Rename Elasticsearch Docker image tag 2017-10-03 17:54:31 +02:00
fluentd-es-configmap.yaml Fix CRI fluentd config. 2017-11-10 20:55:56 +00:00
fluentd-es-ds.yaml Fix CRI fluentd config. 2017-11-10 20:55:56 +00:00
kibana-deployment.yaml fluentd-elasticsearch add-on: Upgrade API versions 2017-10-01 12:28:16 +02:00
kibana-service.yaml Adds the new addon-manager labels on cluster addon templates 2017-02-24 16:53:12 -08:00
OWNERS Added coffeepac to ElasticSearch owners 2017-05-13 07:48:09 +02:00
README.md Refactored the fluentd-es addon files, moved the fluentd configuration to ConfigMap 2017-08-04 20:05:15 +02:00

Elasticsearch Add-On

This add-on consists of a combination of Elasticsearch, Fluentd and Kibana. Elasticsearch is a search engine that is responsible for storing our logs and allowing for them to be queried. Fluentd sends log messages from Kubernetes to Elasticsearch, whereas Kibana is a graphical interface for viewing and querying the logs stored in Elasticsearch.

Note: this addon should not be used as-is in production. This is an example and you should treat is as such. Please see at least the Security and the Storage sections for more information.

Elasticsearch

Elasticsearch is deployed as a StatefulSet, which is like a Deployment, but allows for maintaining state on storage volumes.

Security

Elasticsearch has capabilities to enable authorization using X-Pack plugin. See configuration parameter xpack.security.enabled in Elasticsearch and Kibana configurations. It can also be set via XPACK_SECURITY_ENABLED env variable. After enabling the feature, follow official documentation to set up credentials in Elasticsearch and Kibana. Don't forget to propagate those credentials also to Fluentd in its configuration, using for example environment variables. You can utilize ConfigMaps and Secrets to store credentials in the Kubernetes apiserver.

Initialization

The Elasticsearch Statefulset manifest specifies that there shall be an init container executing before Elasticsearch containers themselves, in order to ensure that the kernel state variable vm.max_map_count is at least 262144, since this is a requirement of Elasticsearch. You may remove the init container if you know that your host OS meets this requirement.

Storage

The Elasticsearch StatefulSet will use the EmptyDir volume to store data. EmptyDir is erased when the pod terminates, here it is used only for testing purposes. Important: please change the storage to persistent volume claim before actually using this StatefulSet in your setup!

Fluentd

Fluentd is deployed as a DaemonSet which spawns a pod on each node that reads logs, generated by kubelet, container runtime and containers and sends them to Elasticsearch.

Note: in order for Fluentd to work, every Kubernetes node must be labeled with beta.kubernetes.io/fluentd-ds-ready=true, as otherwise the Fluentd DaemonSet will ignore them.

Learn more in the official Kubernetes documentation.

Known problems

Since Fluentd talks to the Elasticsearch service inside the cluster, instances on masters won't work, because masters have no kube-proxy. Don't mark masters with a label mentioned in the previous paragraph or add a taint on them to avoid Fluentd pods scheduling there.

Analytics