Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[stable/metricbeat] metricbeat chart (#7347)
Browse files Browse the repository at this point in the history
* [stable/metricbeat] add metricbeat chart

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] add starting space in comment

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] modify api version

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] set latest beat version and update role settings based on official

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] split common config file into daemonset and deployment

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] modify checksum target

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] cleanup daemonset.yaml

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] make serviceAccount.name configurable

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] add matchLabels at deployment.yaml

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] set api ver to v1

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] add OWNERS file

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] modify README

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] extraVars -> extraEnv

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>

* [stable/metricbeat] modify readme

Signed-off-by: Atsushi Kawamura <akawamura@c-fo.com>
  • Loading branch information
at-k authored and k8s-ci-robot committed Sep 23, 2018
1 parent ad307f6 commit e421d6c
Show file tree
Hide file tree
Showing 13 changed files with 607 additions and 0 deletions.
23 changes: 23 additions & 0 deletions stable/metricbeat/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# OWNERS file for Kubernetes
OWNERS
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
14 changes: 14 additions & 0 deletions stable/metricbeat/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
description: A Helm chart to collect Kubernetes logs with metricbeat
icon: https://www.elastic.co/assets/blt47799dcdcf08438d/logo-elastic-beats-lt.svg
name: metricbeat
version: 0.3.0
appVersion: 6.4.0
home: https://www.elastic.co/products/beats/metricbeat
sources:
- https://www.elastic.co/guide/en/beats/metricbeat/current/index.html
maintainers:
- name: at-k
email: atushi.k@gmail.com
- name: mumoshu
email: ykuoka@gmail.com
6 changes: 6 additions & 0 deletions stable/metricbeat/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
approvers:
- at-k
- mumoshu
reviewers:
- at-k
- mumoshu
70 changes: 70 additions & 0 deletions stable/metricbeat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Metricbeat

[metricbeat](https://www.elastic.co/guide/en/beats/metricbeat/current/index.html) is used to ship Kubernetes and host metrics to multiple outputs.

## Prerequisites

- Kubernetes 1.9+

## Installing the Chart

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

```bash
$ helm install --name my-release stable/metricbeat
```

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

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

```bash
$ 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 metricbeat chart and their default values.

| Parameter | Description | Default |
|-------------------------------------|------------------------------------|-------------------------------------------|
| `image.repository` | The image repository to pull from | `docker.elastic.co/beats/metricbeat` |
| `image.tag` | The image tag to pull | `6.4.0` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `rbac.create` | If true, create & use RBAC resources | `true` |
| `serviceAccount.create` | If true, create & use ServiceAccount | `true` |
| `serviceAccount.name` | The name of the ServiceAccount to use. If not set and create is true, a name is generated using the fullname template | |
| `config` | The content of the configuration file consumed by metricbeat. See the [metricbeat.reference.yml](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-reference-yml.html) for full details | |
| `plugins` | List of beat plugins | |
| `extraEnv` | Additional environment | |
| `extraVolumes`, `extraVolumeMounts` | Additional volumes and mounts, for example to provide other configuration files | |
| `resources.requests.cpu` | CPU resource requests | |
| `resources.limits.cpu` | CPU resource limits | |
| `resources.requests.memory` | Memory resource requests | |
| `resources.limits.memory` | Memory resource limits | |
| `daemonset.modules.<name>.config` | The content of the modules configuration file consumed by metricbeat deployed as daemonset, which is assumed to collect metrics in each nodes. See the [metricbeat.reference.yml](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-reference-yml.html) for full details |
| `daemonset.modules.<name>.enabled` | If true, enable configuration | |
| `daemonset.podAnnotations` | Pod annotations for daemonset | |
| `deployment.modules.<name>.config` | The content of the modules configuration file consumed by metricbeat deployed as deployment, which is assumed to collect cluster-level metrics. See the [metricbeat.reference.yml](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-reference-yml.html) for full details ||
| `deployment.modules.<name>.enabled` | If true, enable configuration ||
| `deployment.podAnnotations` | Pod annotations for deployment | |

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

```bash
$ helm install --name my-release \
--set rbac.create=true \
stable/metricbeat
```

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

```bash
$ helm install --name my-release -f values.yaml stable/metricbeat
```

> **Tip**: You can use the default [values.yaml](values.yaml)
3 changes: 3 additions & 0 deletions stable/metricbeat/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To verify that Metricbeat has started, run:

kubectl --namespace={{ .Release.Namespace }} get pods -l "app={{ template "metricbeat.name" . }},release={{ .Release.Name }}"
43 changes: 43 additions & 0 deletions stable/metricbeat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "metricbeat.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 "metricbeat.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 "metricbeat.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "metricbeat.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "metricbeat.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
28 changes: 28 additions & 0 deletions stable/metricbeat/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "metricbeat.fullname" . }}
labels:
app: {{ template "metricbeat.name" . }}
chart: {{ template "metricbeat.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups: [""]
resources:
- nodes
- namespaces
- events
- pods
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources:
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources:
- statefulsets
- deployments
verbs: ["get", "list", "watch"]
{{- end -}}
19 changes: 19 additions & 0 deletions stable/metricbeat/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "metricbeat.fullname" . }}
labels:
app: {{ template "metricbeat.name" . }}
chart: {{ template "metricbeat.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "metricbeat.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "metricbeat.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
119 changes: 119 additions & 0 deletions stable/metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "metricbeat.fullname" . }}
labels:
app: {{ template "metricbeat.name" . }}
chart: {{ template "metricbeat.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
matchLabels:
app: {{ template "metricbeat.name" . }}
release: {{ .Release.Name }}
minReadySeconds: 10
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
app: {{ template "metricbeat.name" . }}
release: {{ .Release.Name }}
annotations:
checksum/daemonset: {{ toYaml .Values.daemonset.modules | sha256sum }}
checksum/config: {{ toYaml .Values.daemonset.config | sha256sum }}
{{- if .Values.daemonset.podAnnotations }}
{{- range $key, $value := .Values.daemonset.podAnnotations }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-e"
{{- if .Values.plugins }}
- "--plugin"
- {{ .Values.plugins | join "," | quote }}
{{- end }}
- "-system.hostfs=/hostfs"
{{- if .Values.daemonset.debug }}
- "-d"
- "*"
{{- end }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if .Values.extraEnv }}
{{ toYaml .Values.extraEnv | indent 8 }}
{{- end }}
securityContext:
runAsUser: 0
resources:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
- name: config
mountPath: /usr/share/metricbeat/metricbeat.yml
readOnly: true
subPath: metricbeat.yml
- name: modules
mountPath: /usr/share/metricbeat/modules.d
readOnly: true
- name: data
mountPath: /usr/share/metricbeat/data
- name: proc
mountPath: /hostfs/proc
readOnly: true
- name: cgroup
mountPath: /hostfs/sys/fs/cgroup
readOnly: true
- name: dockersock
mountPath: /var/run/docker.sock
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
volumes:
- name: config
secret:
secretName: {{ template "metricbeat.fullname" . }}-daemonset-config
- name: modules
secret:
secretName: {{ template "metricbeat.fullname" . }}-daemonset-modules
- name: data
hostPath:
path: /var/lib/metricbeat
type: DirectoryOrCreate
- name: proc
hostPath:
path: /proc
- name: cgroup
hostPath:
path: /sys/fs/cgroup
- name: dockersock
hostPath:
path: /var/run/docker.sock
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- end }}
terminationGracePeriodSeconds: 60
serviceAccountName: {{ template "metricbeat.serviceAccountName" . }}
hostNetwork: true
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
Loading

0 comments on commit e421d6c

Please sign in to comment.