From 34e98ee378bb1577de8642ae62d57a242729969e Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Fri, 17 Jan 2020 12:35:29 +0100 Subject: [PATCH 1/3] Fix DNS lookup failure error for host URLs --- metricbeat/templates/daemonset.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 7fb1cfdf7..e6d22e103 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -84,6 +84,8 @@ spec: imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} {{- end }} + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet containers: - name: "metricbeat" image: "{{ .Values.image }}:{{ .Values.imageTag }}" From 1753ba78a6d7b5f471f217d5108d8b423f7fa01a Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Mon, 17 Feb 2020 10:08:24 +0100 Subject: [PATCH 2/3] hostNetwork and dnsPolicy options configurable --- metricbeat/templates/daemonset.yaml | 4 ++-- metricbeat/tests/metricbeat_test.py | 22 ++++++++++++++++++++++ metricbeat/values.yaml | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index faa823006..e815e8057 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -91,8 +91,8 @@ spec: initContainers: {{ tpl .Values.extraInitContainers . | indent 6 }} {{- end }} - hostNetwork: true - dnsPolicy: ClusterFirstWithHostNet + hostNetwork: {{ .Values.hostNetwork | default false }} + dnsPolicy: {{ .Values.dnsPolicy | default "ClusterFirst" }} containers: - name: "metricbeat" image: "{{ .Values.image }}:{{ .Values.imageTag }}" diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index c20fe252c..79861bd48 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -47,6 +47,28 @@ def test_defaults(): } in volumes +def test_override_the_default_host_network_option(): + config = """ +hostNetwork: true +""" + r = helm_template(config) + assert ( + r["daemonset"][name]["spec"]["template"]["spec"]["hostNetwork"] + == True + ) + + +def test_override_the_default_dns_policy_option(): + config = """ +dnsPolicy: ClusterFirstWithHostNet +""" + r = helm_template(config) + assert ( + r["daemonset"][name]["spec"]["template"]["spec"]["dnsPolicy"] + == "ClusterFirstWithHostNet" + ) + + def test_adding_a_extra_container(): config = """ extraContainers: | diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 3ea4af311..7e7fe1ef3 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -190,6 +190,9 @@ nodeSelector: {} affinity: {} +hostNetwork: false +dnsPolicy: "ClusterFirst" + # This is the PriorityClass settings as defined in # https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass priorityClassName: "" From f5addbe5e74b30c7ad402b2fbca6d03c5e0c70be Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Mon, 17 Feb 2020 10:16:44 +0100 Subject: [PATCH 3/3] Update README.md --- metricbeat/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metricbeat/README.md b/metricbeat/README.md index 77f7c1cee..e47ca56c2 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -84,6 +84,8 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.6.0 | `clusterRoleRules` | Configurable [cluster role rules](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole) that Metricbeat uses to access Kubernetes resources. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml) | | `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` | +| `hostNetworking` | Use host networking in the daemonset so that hostname is reported correctly. **NOTE**: daemonset only | false +| `dnsPolicy` | Configurable [dnsPolicy](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/) **NOTE**: daemonset only | `ClusterFirst` | `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`
`initialDelaySeconds: 10`
`periodSeconds: 10`
`successThreshold: 3`
`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`
`initialDelaySeconds: 10`
`periodSeconds: 10`
`successThreshold: 3`
`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`
`requests.memory: 100Mi`
`limits.cpu: 1000m`
`limits.memory: 200Mi` |