Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions filebeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ as a reference. They are also used in the automated testing of this chart.
| `imagePullSecrets` | Configuration for [imagePullSecrets][] so that you can use a private registry for your image | `[]` |
| `imageTag` | The Filebeat Docker image tag | `8.0.0-SNAPSHOT` |
| `image` | The Filebeat Docker image | `docker.elastic.co/beats/filebeat` |
| `deploymentType` | Whether Filebeat will be deployed as `DaemonSet` running on all Worker nodes (default) or `Deployment` | `daemonset` |
Comment thread
jmlrt marked this conversation as resolved.
Outdated

| `labels` | Configurable [labels][] applied to all Filebeat pods | `{}` |
| `livenessProbe` | Parameters to pass to liveness [probe][] checks for values such as timeouts and thresholds | see [values.yaml][] |
| `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` |
Expand Down
2 changes: 2 additions & 0 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
{{- if eq (printf "%s" (.Values.deploymentType | lower | default "daemonset")) "daemonset" }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -169,3 +170,4 @@ spec:
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
{{- end }}
172 changes: 172 additions & 0 deletions filebeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
{{- if eq (printf "%s" .Values.deploymentType | lower) "deployment" }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "filebeat.fullname" . }}
labels:
app: "{{ template "filebeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Comment thread
jmlrt marked this conversation as resolved.
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Comment thread
jmlrt marked this conversation as resolved.
spec:
selector:
matchLabels:
app: "{{ template "filebeat.fullname" . }}"
release: {{ .Release.Name | quote }}
Comment thread
jmlrt marked this conversation as resolved.
template:
metadata:
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{/* This forces a restart if the configmap has changed */}}
{{- if .Values.filebeatConfig }}
configChecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
{{- end }}
name: "{{ template "filebeat.fullname" . }}"
labels:
app: "{{ template "filebeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.tolerations }}
tolerations: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- with .Values.affinity }}
affinity: {{ toYaml . | nindent 8 -}}
{{- end }}
serviceAccountName: {{ template "filebeat.serviceAccount" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
{{- if .Values.hostNetworking }}
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
volumes:
{{- range .Values.secretMounts }}
- name: {{ .name }}
secret:
secretName: {{ .secretName }}
{{- end }}
{{- if .Values.filebeatConfig }}
- name: filebeat-config
configMap:
defaultMode: 0600
name: {{ template "filebeat.fullname" . }}-config
{{- end }}
- name: data
hostPath:
path: {{ .Values.hostPathRoot }}/{{ template "filebeat.fullname" . }}-{{ .Release.Namespace }}-data
type: DirectoryOrCreate
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log
- name: varrundockersock
hostPath:
path: /var/run/docker.sock
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
{{- if .Values.extraInitContainers }}
initContainers:
# All the other beats accept a string here while
# filebeat accepts a valid yaml array. We're keeping
# this as a backwards compatible change, while adding
# also a way to pass a string as other templates to
# make these implementations consistent.
# https://github.com/elastic/helm-charts/issues/490
{{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
{{ tpl .Values.extraInitContainers . | indent 8 }}
{{- else }}
{{ toYaml .Values.extraInitContainers | indent 8 }}
{{- end }}
{{- end }}
containers:
- name: "filebeat"
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
args:
- "-e"
- "-E"
- "http.enabled=true"
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 10 }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
resources:
{{ toYaml .Values.resources | indent 10 }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
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 }}
{{- end }}
volumeMounts:
{{- range .Values.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 }}
{{- end }}
- name: data
mountPath: /usr/share/filebeat/data
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: varlog
mountPath: /var/log
readOnly: true
# Necessary when using autodiscovery; avoid mounting it otherwise
# See: https://www.elastic.co/guide/en/beats/filebeat/master/configuration-autodiscover.html
- name: varrundockersock
mountPath: /var/run/docker.sock
readOnly: true
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}

{{- end }}
32 changes: 32 additions & 0 deletions filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def test_defaults():
assert c["name"] == project
assert c["image"].startswith("docker.elastic.co/beats/" + project + ":")

assert c["deploymentType"] == "daemonset"

assert c["env"][0]["name"] == "POD_NAMESPACE"
assert c["env"][0]["valueFrom"]["fieldRef"]["fieldPath"] == "metadata.namespace"

Expand Down Expand Up @@ -400,3 +402,33 @@ def test_setting_fullnameOverride():
"type": "DirectoryOrCreate",
},
} in volumes


def test_deployment_type_deployment():
config = """
deploymentType: 'deployment'
"""
r = helm_template(config)

assert "daemonset" not in r
assert r["deployment"]


def test_deployment_type_daemonset():
config = """
deploymentType: 'daemonset'
"""
r = helm_template(config)

assert "deployment" not in r
assert r["daemonset"]


def test_deployment_type_case_insensitive():
config = """
deploymentType: 'DePloYmEnT'
"""
r = helm_template(config)

assert "daemonset" not in r
assert r["deployment"]
3 changes: 3 additions & 0 deletions filebeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ imageTag: "8.0.0-SNAPSHOT"
imagePullPolicy: "IfNotPresent"
imagePullSecrets: []

# Choice between DaemonSet (default) and Deployment
deploymentType: daemonset

livenessProbe:
exec:
command:
Expand Down