Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Add metricbeat chart #127

Merged
merged 15 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers/bumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

file_patterns = [
'*/examples/*/test/goss.y*ml',
'*/examples/*/test/goss*.y*ml',
'*/examples/*/*.y*ml',
'*/README.md',
'*/values.y*ml',
Expand Down
7 changes: 6 additions & 1 deletion helpers/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ default: test
.ONESHELL:

lint:
grep 'charts/' ./.helmignore || echo 'charts/' >> ./.helmignore
helm lint --strict ./

template:
Expand All @@ -15,7 +16,11 @@ build:
pytest:
pytest -sv --color=yes

test-all: template lint pytest
deps:
sed --in-place '/charts\//d' ./.helmignore
helm dependency update

test-all: lint deps template pytest

test: build
docker run --rm -i --user "$$(id -u):$$(id -g)" -v $$(pwd)/../:/app -w /app/$$(basename $$(pwd)) helm-tester make test-all
Expand Down
8 changes: 5 additions & 3 deletions helpers/examples.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
GOSS_VERSION := v0.3.6
GOSS_FILE ?= goss.yaml
GOSS_SELECTOR ?= release=$(RELEASE)

goss:
GOSS_CONTAINER=$$(kubectl get pods -l release=$(RELEASE) -o name | awk -F'/' 'NR==1{ print $$NF }') && \
GOSS_CONTAINER=$$(kubectl get --no-headers=true pods -l $(GOSS_SELECTOR) -o custom-columns=:metadata.name | sed -n 1p ) && \
echo Testing with pod: $$GOSS_CONTAINER && \
kubectl cp test/*.yaml $$GOSS_CONTAINER:/tmp/goss.yaml && \
kubectl exec $$GOSS_CONTAINER -- sh -c "cd /tmp/ && curl -s -L https://github.com/aelsabbahy/goss/releases/download/$(GOSS_VERSION)/goss-linux-amd64 -o goss && chmod +rx ./goss && ./goss validate --retry-timeout 30s --sleep 5s --color --format documentation"
kubectl cp test/$(GOSS_FILE) $$GOSS_CONTAINER:/tmp/$(GOSS_FILE) && \
kubectl exec $$GOSS_CONTAINER -- sh -c "cd /tmp/ && curl -s -L https://github.com/aelsabbahy/goss/releases/download/$(GOSS_VERSION)/goss-linux-amd64 -o goss && chmod +rx ./goss && ./goss --gossfile $(GOSS_FILE) validate --retry-timeout 30s --sleep 5s --color --format documentation"

4 changes: 3 additions & 1 deletion helpers/helm-tester/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ ENV HELM_VERSION=2.14.0
RUN wget https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
tar xfv helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ && \
rm -rf linux-amd64
rm -rf linux-amd64 && \
HOME=/ helm init --client-only && \
chmod 777 -R /.helm
3 changes: 3 additions & 0 deletions helpers/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FILEBEAT_SUITE:
- 6.x
METRICBEAT_SUITE:
- default
- oss
- security
- 6.x
KUBERNETES_VERSION:
- '1.11'
- '1.12'
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
description: Metricbeat
description: Official Elastic helm chart for Metricbeat
home: https://github.com/elastic/helm-charts
maintainers:
- email: [email protected]
name: Elastic
name: metricbeat
version: 7.0.1-alpha1
appVersion: 7.0.1
version: 7.2.0
appVersion: 7.2.0
sources:
- https://github.com/elastic/beats
icon: https://helm.elastic.co/icons/metricbeat.png
33 changes: 17 additions & 16 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Metricbeat Helm Chart

This functionality is in alpha status and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but alpha features are not subject to the support SLA of official GA features.
This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

This helm chart is a lightweight way to configure and run our official [Metricbeat docker image](https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html).

Expand All @@ -17,49 +17,50 @@ This helm chart is a lightweight way to configure and run our official [Metricbe
```
* Install it
```
helm install --name metricbeat elastic/metricbeat --version 7.0.1-alpha1
helm install --name metricbeat elastic/metricbeat --version 7.2.0
```

## Compatibility

This chart is tested with the latest supported versions. The currently tested versions are:

| 5.x | 6.x | 7.x |
| ------ | ----- | ----- |
| 5.6.16 | 6.7.2 | 7.0.1 |
| 6.x | 7.x |
| ----- | ----- |
| 6.8.1 | 7.2.0 |

Examples of installing older major versions can be found in the [examples](./examples) directory.

While only the latest releases are tested, it is possible to easily install old or new releases by overriding the `imageTag`. To install version `7.0.1` of metricbeat it would look like this:
While only the latest releases are tested, it is possible to easily install old or new releases by overriding the `imageTag`. To install version `7.2.0` of metricbeat it would look like this:

```
helm install --name metricbeat elastic/metricbeat --version 7.0.1-alpha1 --set imageTag=7.0.1
helm install --name metricbeat elastic/metricbeat --version 7.2.0 --set imageTag=7.2.0
```


## Configuration
| Parameter | Description | Default |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml`. See [values.yaml](./values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](./values.yaml) |
| `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml`. See [values.yaml](./values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](./values.yaml) |
| `extraEnvs` | Extra [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config) which will be appended to the `env:` definition for the container | `[]` |
| `extraVolumeMounts` | Any extra volumes mounts to define for the Metricbeat container | `[]` |
| `extraVolumeMounts` | Any extra volumes mounts to define for the Metricbeat container | `[]` |
| `extraVolumes` | Any extra volumes to define for the pod | `[]` |
| `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Metricbeat registry data | `/var/lib` |
| `image` | The Metricbeat docker image | `docker.elastic.co/beats/metricbeat` |
| `imageTag` | The Metricbeat docker image tag | `7.0.1` |
| `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Metricbeat registry data | `/var/lib` |
| `image` | The Metricbeat docker image | `docker.elastic.co/beats/metricbeat` |
| `imageTag` | The Metricbeat docker image tag | `7.2.0` |
| `imagePullPolicy` | The Kubernetes [imagePullPolicy](https://kubernetes.io/docs/concepts/containers/images/#updating-images) value | `IfNotPresent` |
| `imagePullSecrets` | Configuration for [imagePullSecrets](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret) so that you can use a private registry for your image | `[]` |
| `managedServiceAccount` | Whether the `serviceAccount` should be managed by this helm chart. Set this to `false` in order to manage your own service account and related roles. | `true` |
| `podAnnotations` | Configurable [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) applied to all Metricbeat pods | `{}` |
| `podSecurityContext` | Configurable [podSecurityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) for Metricbeat pod execution environment | `fsGroup: 1000`<br>`runAsUser: 0`<br>`privileged: false` |
| `podAnnotations` | Configurable [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) applied to all Metricbeat pods | `{}` |
| `podSecurityContext` | Configurable [podSecurityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) for Metricbeat pod execution environment | `runAsUser: 0`<br>`privileged: false` |
| `livenessProbe` | Parameters to pass to [liveness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) checks for values such as timeouts and thresholds. | `failureThreshold: 3`<br>`initialDelaySeconds: 10`<br>`periodSeconds: 10`<br>`successThreshold: 3`<br>`timeoutSeconds: 5` |
| `readinessProbe` | Parameters to pass to [readiness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) checks for values such as timeouts and thresholds. | `failureThreshold: 3`<br>`initialDelaySeconds: 10`<br>`periodSeconds: 10`<br>`successThreshold: 3`<br>`timeoutSeconds: 5` |
| `resources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the `DaemonSet` | `requests.cpu: 100m`<br>`requests.memory: 100Mi`<br>`limits.cpu: 1000m`<br>`limits.memory: 200Mi` |
| `serviceAccount` | Custom [serviceAccount](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/) that Metricbeat will use during execution. By default will use the service account created by this chart. | `""` |
| `serviceAccount` | Custom [serviceAccount](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/) that Metricbeat will use during execution. By default will use the service account created by this chart. | `""` |
| `secretMounts` | Allows you easily mount a secret as a file inside the `DaemonSet`. Useful for mounting certificates and other secrets. See [values.yaml](./values.yaml) for an example | `[]` |
| `terminationGracePeriod` | Termination period (in seconds) to wait before killing Metricbeat pod process on pod shutdown | `30` |
| `terminationGracePeriod` | Termination period (in seconds) to wait before killing Metricbeat pod process on pod shutdown | `30` |
| `tolerations` | Configurable [tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) | `[]` |
| `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) for the `DaemonSet`. By default Kubernetes will kill and recreate pods on updates. Setting this to `OnDelete` will require that pods be deleted manually. | `RollingUpdate` |
| `replicas` | The replica count for the metricbeat deployment talking to kube-state-metrics | `1` |

## Examples

Expand Down
17 changes: 17 additions & 0 deletions metricbeat/examples/6.x/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default: test

include ../../../helpers/examples.mk

RELEASE := helm-metricbeat-six
GOSS_SELECTOR = release=$(RELEASE),app=helm-metricbeat-six-metricbeat

install:
helm upgrade --wait --timeout=600 --install $(RELEASE) --values values.yaml ../../

purge:
helm del --purge $(RELEASE)

test-metrics:
GOSS_FILE=goss-metrics.yaml make goss GOSS_SELECTOR=release=$(RELEASE),app=helm-metricbeat-six-metricbeat-metrics

test: install goss test-metrics
45 changes: 45 additions & 0 deletions metricbeat/examples/6.x/test/goss-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
port:
tcp:5066:
listening: true
ip:
- '127.0.0.1'

mount:
/usr/share/metricbeat/data:
exists: true
/usr/share/metricbeat/kube-state-metrics-metricbeat.yml:
exists: true
opts:
- ro

user:
metricbeat:
exists: true
uid: 1000
gid: 1000

http:
http://six-master:9200/_cat/indices:
status: 200
timeout: 2000
body:
- 'metricbeat-6.8.1'
http://six-master:9200/_search?q=metricset.name:state_deployment:
status: 200
timeout: 2000
body:
- 'metricbeat-6.8.1'

file:
/usr/share/metricbeat/metricbeat.yml:
exists: true
contains:
- 'add_kubernetes_metadata'
- 'output.elasticsearch'

command:
cd /usr/share/metricbeat && metricbeat test output:
exit-status: 0
stdout:
- 'elasticsearch: http://six-master:9200'
- 'version: 6.8.1'
Loading