Skip to content

Commit

Permalink
added fluentd elastisearch
Browse files Browse the repository at this point in the history
  • Loading branch information
André Bauer committed Dec 21, 2018
1 parent ef1275e commit b6b002c
Show file tree
Hide file tree
Showing 15 changed files with 1,014 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/fluentd-elasticsearch/Chart.yaml
@@ -0,0 +1,21 @@
name: fluentd-elasticsearch
version: 2.1.0
appVersion: 2.3.2
home: https://www.fluentd.org/
description: A Fluentd Helm chart for Kubernetes with Elasticsearch output
icon: https://raw.githubusercontent.com/fluent/fluentd-docs/master/public/logo/Fluentd_square.png
keywords:
- fluentd
- elasticsearch
- multiline
- detect-exceptions
- logging
sources:
- https://github.com/kubernetes/charts/stable/fluentd-elasticsearch
- https://github.com/fluent/fluentd-kubernetes-daemonset
- https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions
- https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsearch/fluentd-es-image
maintainers:
- name: monotek
email: monotek23@gmail.com
engine: gotpl
6 changes: 6 additions & 0 deletions charts/fluentd-elasticsearch/OWNERS
@@ -0,0 +1,6 @@
approvers:
- axdotl
- monotek
reviewers:
- axdotl
- monotek
95 changes: 95 additions & 0 deletions charts/fluentd-elasticsearch/README.md
@@ -0,0 +1,95 @@
# Fluentd Elasticsearch

* Installs [Fluentd](https://www.fluentd.org/) log forwarder.

## TL;DR;

```console
$ helm install stable/fluentd-elasticsearch
```

## Introduction

This chart bootstraps a [Fluentd](https://www.fluentd.org/) daemonset on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
It's meant to be a drop in replacement for fluentd-gcp on GKE which sends logs to Google's Stackdriver service, but can also be used in other places where logging to ElasticSearch is required.
The used Docker image also contains Google's detect exceptions (for Java multiline stacktraces), Prometheus exporter, Kubernetes metadata filter & Systemd plugins.

## Prerequisites

- Kubernetes 1.8+ with Beta APIs enabled

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install --name my-release stable/fluentd-elasticsearch
```

The command deploys fluentd-elasticsearch on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the Fluentd elasticsearch chart and their default values.


| Parameter | Description | Default |
| ---------------------------------- | ------------------------------------------ | ---------------------------------------------------------- |
| `annotations` | Optional daemonset annotations | `NULL` |
| `configMaps` | Fluentd configmaps | `default conf files` |
| `elasticsearch.host` | Elasticsearch Host | `elasticsearch-client` |
| `elasticsearch.port` | Elasticsearch Port | `9200` |
| `elasticsearch.logstash_prefix` | Elasticsearch Logstash prefix | `logstash` |
| `elasticsearch.buffer_chunk_limit` | Elasticsearch buffer chunk limit | `2M` |
| `elasticsearch.buffer_queue_limit` | Elasticsearch buffer queue limit | `8` |
| `elasticsearch.scheme` | Elasticsearch scheme setting | `http` |
| `env` | List of environment variables that are added to the fluentd pods | `{}` |
| `extraVolumeMounts` | Mount an extra volume, required to mount ssl certificates when elasticsearch has tls enabled | |
| `extraVolume` | Extra volume | |
| `image.repository` | Image | `gcr.io/google-containers/fluentd-elasticsearch` |
| `image.tag` | Image tag | `v2.3.2` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `livenessProbe.enabled` | Whether to enable livenessProbe | `true` |
| `nodeSelector` | Optional daemonset nodeSelector | `{}` |
| `podSecurityPolicy.annotations` | Specify pod annotations in the pod security policy | `{}` |
| `podSecurityPolicy.enabled` | Specify if a pod security policy must be created | `false` |
| `rbac.create` | RBAC | `true` |
| `resources.limits.cpu` | CPU limit | `100m` |
| `resources.limits.memory` | Memory limit | `500Mi` |
| `resources.requests.cpu` | CPU request | `100m` |
| `resources.requests.memory` | Memory request | `200Mi` |
| `service` | Service definition | `{}` |
| `service.type` | Service type (ClusterIP/NodePort) | Not Set |
| `service.ports` | List of service ports dict [{name:...}...] | Not Set |
| `service.ports[].name` | One of service ports name | Not Set |
| `service.ports[].port` | Service port | Not Set |
| `service.ports[].nodePort` | NodePort port (when service.type is NodePort) | Not Set |
| `service.ports[].protocol` | Service protocol(optional, can be TCP/UDP) | Not Set |
| `serviceAccount.create` | Specifies whether a service account should be created.| `true` |
| `serviceAccount.name` | Name of the service account. | |
| `tolerations` | Optional daemonset tolerations | `{}` |
| `updateStrategy` | Optional daemonset update strategy | `type: RollingUpdate` |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```console
$ helm install --name my-release \
stable/fluentd-elasticsearch
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```console
$ helm install --name my-release -f values.yaml stable/fluentd-elasticsearch
```
24 changes: 24 additions & 0 deletions charts/fluentd-elasticsearch/templates/NOTES.txt
@@ -0,0 +1,24 @@
1. To verify that Fluentd has started, run:

kubectl --namespace={{ .Release.Namespace }} get pods -l "app.kubernetes.io/name={{ include "fluentd-elasticsearch.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"

THIS APPLICATION CAPTURES ALL CONSOLE OUTPUT AND FORWARDS IT TO elasticsearch . Anything that might be identifying,
including things like IP addresses, container images, and object names will NOT be anonymized.

{{- if .Values.service }}
2. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "fluentd-elasticsearch.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "fluentd-elasticsearch.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "fluentd-elasticsearch.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "fluentd-elasticsearch.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions charts/fluentd-elasticsearch/templates/_helpers.tpl
@@ -0,0 +1,42 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "fluentd-elasticsearch.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "fluentd-elasticsearch.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "fluentd-elasticsearch.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "fluentd-elasticsearch.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "fluentd-elasticsearch.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
23 changes: 23 additions & 0 deletions charts/fluentd-elasticsearch/templates/clusterrole.yaml
@@ -0,0 +1,23 @@
{{- if .Values.rbac.create -}}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "fluentd-elasticsearch.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
helm.sh/chart: {{ include "fluentd-elasticsearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
rules:
- apiGroups:
- ""
resources:
- "namespaces"
- "pods"
verbs:
- "get"
- "watch"
- "list"
{{- end -}}
21 changes: 21 additions & 0 deletions charts/fluentd-elasticsearch/templates/clusterrolebinding.yaml
@@ -0,0 +1,21 @@
{{- if .Values.rbac.create -}}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "fluentd-elasticsearch.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
helm.sh/chart: {{ include "fluentd-elasticsearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
subjects:
- kind: ServiceAccount
name: {{ template "fluentd-elasticsearch.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "fluentd-elasticsearch.fullname" . }}
apiGroup: rbac.authorization.k8s.io
{{- end -}}
16 changes: 16 additions & 0 deletions charts/fluentd-elasticsearch/templates/configmap.yaml
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fluentd-elasticsearch.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
helm.sh/chart: {{ include "fluentd-elasticsearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
data:
{{- range $key, $value := .Values.configMaps }}
{{ $key }}: |-
{{ $value | indent 4 }}
{{- end }}

0 comments on commit b6b002c

Please sign in to comment.