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

[filebeat] deployment support feature #964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ed1fbf6
Support for Deployment Kubernetes resource
Sep 24, 2020
2e1a6d6
Tests on 'deploymentType' YAML directive
Sep 24, 2020
959abbf
Similar to Metricbeat Templating
Oct 21, 2020
481104e
Fix double value in `filebeat/values.yaml`
Nov 2, 2020
eaa12c6
Fix missing parameter in Filebeat Deployment template
Nov 2, 2020
9632ad8
Merge branch 'master' into filebeat-deployment-support-feature
operatorequals Nov 2, 2020
fe60db0
Update filebeat/templates/configmap.yaml
operatorequals Nov 19, 2020
f4f0734
Update filebeat/templates/configmap.yaml
operatorequals Nov 19, 2020
8e3a2a5
Update filebeat/templates/daemonset.yaml
operatorequals Nov 24, 2020
717cbe5
Resolving comments for 8e3a2a530a94963033b2c9a98632ce3ef27653cb
Nov 26, 2020
dca3974
Add explanation for deployment/daemonset values scheme
Nov 26, 2020
332188a
Set toleration defaults to empty list
Dec 2, 2020
afd58f2
Merge branch 'master' into filebeat-deployment-support-feature
operatorequals Dec 5, 2020
0935040
Added replicas Value for deployment
Dec 5, 2020
a8af38b
Fixed all suggestions
Dec 5, 2020
f4346a6
updated daemonset hostNetworking
Dec 5, 2020
d82ad0d
Merge branch 'filebeat-deployment-support-feature' of github.com:oper…
Dec 5, 2020
f6eb5f9
Add Labels in deployment pods
Dec 6, 2020
8404054
rename mountpoint of daemonset data
Dec 6, 2020
3448e07
Made deployment non-root, enabled by default to pass tests
Dec 6, 2020
34f339d
Refactored tests to pass on default-ON Deployment and daemonset with …
Dec 6, 2020
4c463bf
Changed Filebeat deployment UserID to 0 from 1001 as it cannot read t…
Dec 8, 2020
6618cf5
Fixed python linting
Dec 8, 2020
46888b3
Merge branch 'master' into filebeat-deployment-support-feature
operatorequals Dec 14, 2020
6a27ef6
Fix linting in python
Dec 14, 2020
e69c6c1
Added default HTTP input Deployment configuration
Dec 14, 2020
4a204b9
Fix OSS integration test
Dec 16, 2020
51d8410
Fix Security Integration test
Dec 16, 2020
3646043
[filebeat] handle hostAliases for deployment
jmlrt Dec 16, 2020
4da932b
nit - move toleration tests together
jmlrt Dec 16, 2020
a8e5ded
fixup! [filebeat] handle hostAliases for deployment
jmlrt Dec 16, 2020
c548a20
Revert the namespace change in volumeMount
Dec 16, 2020
d7eed6f
Merge branch 'filebeat-deployment-support-feature' of github.com:oper…
Dec 16, 2020
9623f48
Made Deployment non-default
Dec 16, 2020
be0a49a
Changed all tests to enable Deployment
Dec 16, 2020
e3a1178
Python linting
Dec 16, 2020
339bf39
Integration test for deployment
Dec 16, 2020
b218547
Reverted Security integration test
Dec 16, 2020
8126d64
[filebeat] update tests for filebeat deployment
jmlrt Dec 18, 2020
a4eb430
[filebeat] add deployment test to ci
jmlrt Dec 18, 2020
6e6978f
Linting again
Dec 18, 2020
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
109 changes: 71 additions & 38 deletions filebeat/README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions filebeat/examples/deployment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default: test

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

RELEASE := helm-filebeat-deployment

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

test: install goss

purge:
helm del $(RELEASE)
27 changes: 27 additions & 0 deletions filebeat/examples/deployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Default

This example deploy Filebeat 8.0.0-SNAPSHOT using [default values][] as a Kubernetes Deployment.


## Usage

* Deploy [Elasticsearch Helm chart][].

* Deploy Filebeat chart with the default values: `make install`

* You can now setup a port forward to query Filebeat indices:

```
kubectl port-forward svc/elasticsearch-master 9200
curl localhost:9200/_cat/indices
```


## Testing

You can also run [goss integration tests][] using `make test`


[elasticsearch helm chart]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/default/
[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/filebeat/examples/deployment/test/goss.yaml
[default values]: https://github.com/elastic/helm-charts/tree/master/filebeat/values.yaml
6 changes: 6 additions & 0 deletions filebeat/examples/deployment/test/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
http:
http://elasticsearch-master:9200/_cat/indices:
status: 200
timeout: 2000
body:
- 'filebeat-8.0.0'
16 changes: 16 additions & 0 deletions filebeat/examples/deployment/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
deployment:
enabled: true

daemonset:
enabled: false

filebeatConfig:
filebeat.yml: |
filebeat.inputs:
- type: log
paths:
- /usr/share/filebeat/logs/filebeat

output.elasticsearch:
host: '${NODE_NAME}'
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}'
36 changes: 36 additions & 0 deletions filebeat/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,39 @@ data:
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if and .Values.daemonset.enabled .Values.daemonset.filebeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "filebeat.fullname" . }}-daemonset-config
labels:
app: "{{ template "filebeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.daemonset.filebeatConfig }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if and .Values.deployment.enabled .Values.deployment.filebeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "filebeat.fullname" . }}-deployment-config
labels:
app: "{{ template "filebeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.deployment.filebeatConfig }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}
80 changes: 50 additions & 30 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.daemonset.enabled }}
---
apiVersion: apps/v1
kind: DaemonSet
Expand All @@ -8,9 +9,21 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- if .Values.daemonset.labels }}
{{- range $key, $value := .Values.daemonset.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- else }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if .Values.daemonset.annotations }}
annotations:
{{- range $key, $value := .Values.daemonset.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
selector:
matchLabels:
Expand All @@ -25,7 +38,7 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
{{/* This forces a restart if the configmap has changed */}}
{{- if .Values.filebeatConfig }}
{{- if or .Values.filebeatConfig .Values.daemonset.filebeatConfig }}
configChecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
{{- end }}
name: "{{ template "filebeat.fullname" . }}"
Expand All @@ -34,36 +47,36 @@ spec:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- if .Values.daemonset.labels }}
{{- range $key, $value := .Values.daemonset.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- else }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
{{- with .Values.tolerations }}
tolerations: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
tolerations: {{ toYaml ( .Values.tolerations | default .Values.daemonset.tolerations ) | nindent 8 }}
nodeSelector: {{ toYaml ( .Values.nodeSelector | default .Values.daemonset.nodeSelector ) | nindent 8 }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- with .Values.affinity }}
affinity: {{ toYaml . | nindent 8 -}}
{{- end }}
affinity: {{ toYaml ( .Values.affinity | default .Values.daemonset.affinity ) | nindent 8 }}
serviceAccountName: {{ template "filebeat.serviceAccount" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
{{- if .Values.hostNetworking }}
{{- if .Values.daemonset.hostNetworking }}
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig: {{ toYaml .Values.dnsConfig | nindent 8 }}
{{- end }}
{{- if .Values.hostAliases }}
hostAliases: {{ toYaml .Values.hostAliases | nindent 6 }}
{{- if .Values.hostAliases | default .Values.daemonset.hostAliases }}
hostAliases: {{ toYaml ( .Values.hostAliases | default .Values.daemonset.hostAliases ) | nindent 8 }}
{{- end }}
volumes:
{{- range .Values.secretMounts }}
{{- range .Values.secretMounts | default .Values.daemonset.secretMounts }}
- name: {{ .name }}
secret:
secretName: {{ .secretName }}
Expand All @@ -73,6 +86,11 @@ spec:
configMap:
defaultMode: 0600
name: {{ template "filebeat.fullname" . }}-config
{{- else if .Values.daemonset.filebeatConfig }}
- name: filebeat-config
configMap:
defaultMode: 0600
name: {{ template "filebeat.fullname" . }}-daemonset-config
{{- end }}
- name: data
hostPath:
Expand All @@ -87,8 +105,8 @@ spec:
- name: varrundockersock
hostPath:
path: /var/run/docker.sock
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- if .Values.extraVolumes | default .Values.daemonset.extraVolumes }}
{{ toYaml ( .Values.extraVolumes | default .Values.daemonset.extraVolumes ) | indent 6 }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -121,7 +139,7 @@ spec:
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
resources:
{{ toYaml .Values.resources | indent 10 }}
{{ toYaml ( .Values.resources | default .Values.daemonset.resources ) | indent 10 }}
env:
- name: POD_NAMESPACE
valueFrom:
Expand All @@ -131,31 +149,32 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if .Values.extraEnvs }}
{{ toYaml .Values.extraEnvs | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 10 }}
{{- if .Values.extraEnvs | default .Values.daemonset.extraEnvs }}
{{ toYaml ( .Values.extraEnvs | default .Values.daemonset.extraEnvs ) | indent 8 }}
{{- end }}
envFrom: {{ toYaml ( .Values.envFrom | default .Values.daemonset.envFrom ) | nindent 10 }}
securityContext: {{ toYaml ( .Values.podSecurityContext | default .Values.daemonset.securityContext ) | nindent 10 }}
volumeMounts:
{{- range .Values.secretMounts }}
{{- range .Values.secretMounts | default .Values.daemonset.secretMounts }}
- name: {{ .name }}
mountPath: {{ .path }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- range $path, $config := .Values.filebeatConfig }}
- name: filebeat-config
mountPath: /usr/share/filebeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{ else }}
{{- range $path, $config := .Values.daemonset.filebeatConfig }}
- name: filebeat-config
mountPath: /usr/share/filebeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{- end }}
{{- end }}
- name: data
mountPath: /usr/share/filebeat/data
- name: varlibdockercontainers
Expand All @@ -169,9 +188,10 @@ spec:
- name: varrundockersock
mountPath: /var/run/docker.sock
readOnly: true
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- if .Values.extraVolumeMounts | default .Values.daemonset.extraVolumeMounts }}
{{ toYaml (.Values.extraVolumeMounts | default .Values.daemonset.extraVolumeMounts ) | indent 8 }}
{{- end }}
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
{{- end }}
Loading