From 8e2beae720deca635376bb35267481b720efd466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20LOISELET?= Date: Fri, 10 Jan 2020 15:22:04 +0100 Subject: [PATCH 1/2] [metricbeat] Added hostNetwork setting --- metricbeat/README.md | 1 + metricbeat/templates/daemonset.yaml | 4 ++++ metricbeat/values.yaml | 3 +++ 3 files changed, 8 insertions(+) diff --git a/metricbeat/README.md b/metricbeat/README.md index 3247c02d9..6791208f2 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -49,6 +49,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.3.0 | `imageTag` | The Metricbeat docker image tag | `7.3.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 | `[]` | +| `daemonsetHostNetworking` | Parameter to enable hostNetwork on the daemonset pods. | `false` | | `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 | `runAsUser: 0`
`privileged: false` | diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index a86850e50..a247e3788 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -32,6 +32,10 @@ spec: heritage: {{ .Release.Service | quote }} release: {{ .Release.Name | quote }} spec: + {{- if .Values.daemonsetHostNetworking }} + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + {{- end }} {{- with .Values.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index c088a8793..f21f5baca 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -90,6 +90,9 @@ imageTag: "7.3.0" imagePullPolicy: "IfNotPresent" imagePullSecrets: [] +# Setting this to true allow kibana's Infrastructure panel to have the node's name instead of the pod's name +daemonsetHostNetworking: false + livenessProbe: failureThreshold: 3 initialDelaySeconds: 10 From c4d5f152dbfee2a36a428b4cf096d75b85baae35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20LOISELET?= Date: Fri, 10 Jan 2020 15:33:27 +0100 Subject: [PATCH 2/2] [metricbeat] added Tests --- metricbeat/tests/metricbeat_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index a274b6a90..0042c5770 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -207,3 +207,11 @@ def test_adding_an_affinity_rule(): r = helm_template(config) assert r['daemonset'][name]['spec']['template']['spec']['affinity']['podAntiAffinity'][ 'requiredDuringSchedulingIgnoredDuringExecution'][0]['topologyKey'] == 'kubernetes.io/hostname' + +def test_daemonset_host_networking(): + config = ''' +daemonsetHostNetworking: true +''' + r = helm_template(config) + assert r['daemonset'][name]['spec']['template']['spec']['hostNetwork'] is True + assert r['daemonset'][name]['spec']['template']['spec']['dnsPolicy'] == "ClusterFirstWithHostNet" \ No newline at end of file