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` |
diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml
index 392b7cf84..e815e8057 100644
--- a/metricbeat/templates/daemonset.yaml
+++ b/metricbeat/templates/daemonset.yaml
@@ -91,6 +91,8 @@ spec:
initContainers:
{{ tpl .Values.extraInitContainers . | indent 6 }}
{{- end }}
+ 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: ""