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

[metricbeat] add host networking option #585

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
[metricbeat] add host networking option
  • Loading branch information
jmlrt committed Apr 17, 2020
commit 28abc498954d919628e72743a96071eef0fcb12f
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.6.2
| `daemonset.extraEnvs` | Extra [environment variables][] which will be appended to Metricbeat container for `DaemonSet`. | `[]` |
| `daemonset.extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function or `DaemonSet`. | `[]` |
| `daemonset.extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function or `DaemonSet`. | `[]` |
| `daemonset.hostNetworking` | Enable Metricbeat `DaemonSet` to use host network | `false` |
| `daemonset.metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml` for Metricbeat `DaemonSet`. | see [values.yaml][] |
| `daemonset.nodeSelector` | Configurable [nodeSelector][] for Metricbeat `DaemonSet`. | `{}` |
| `daemonset.secretMounts` | Allows you easily mount a secret as a file inside the `DaemonSet`. Useful for mounting certificates and other secrets. See [values.yaml][] for an example | `[]` |
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ spec:
affinity: {{ toYaml ( .Values.affinity | default .Values.daemonset.affinity ) | nindent 8 }}
nodeSelector: {{ toYaml ( .Values.nodeSelector | default .Values.daemonset.nodeSelector ) | nindent 8 }}
tolerations: {{ toYaml ( .Values.tolerations | default .Values.daemonset.tolerations ) | nindent 8 }}
{{- if .Values.daemonset.hostNetworking }}
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
Expand Down
33 changes: 33 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def test_defaults():
assert "metricbeat test output" in c["readinessProbe"]["exec"]["command"][-1]

assert r["daemonset"][name]["spec"]["template"]["spec"]["tolerations"] == []

assert "hostNetwork" not in r["daemonset"][name]["spec"]["template"]["spec"]
assert "dnsPolicy" not in r["daemonset"][name]["spec"]["template"]["spec"]
assert (
"hostNetwork"
not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]
)
assert (
"dnsPolicy"
not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]
)

assert (
r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]["tolerations"]
== []
Expand Down Expand Up @@ -249,6 +261,27 @@ def test_adding_image_pull_secrets():
)


def test_adding_host_networking():
config = """
daemonset:
hostNetworking: true
"""
r = helm_template(config)
assert r["daemonset"][name]["spec"]["template"]["spec"]["hostNetwork"] is True
assert (
r["daemonset"][name]["spec"]["template"]["spec"]["dnsPolicy"]
== "ClusterFirstWithHostNet"
)
assert (
"hostNetwork"
not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]
)
assert (
"dnsPolicy"
not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]
)


def test_adding_tolerations():
config = """
daemonset:
Expand Down
1 change: 1 addition & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ daemonset:
# - name: extras
# mountPath: /usr/share/extras
# readOnly: true
hostNetworking: false
# Allows you to add any config files in /usr/share/metricbeat
# such as metricbeat.yml for daemonset
metricbeatConfig:
Expand Down