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

Commit

Permalink
Merge pull request #585 from jmlrt/metricbeat-hostnetwork
Browse files Browse the repository at this point in the history
[metricbeat] add host networking option
  • Loading branch information
jmlrt authored and mgreau committed Apr 17, 2020
1 parent f74d721 commit f59b2c8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This chart is tested with the latest 7.7.0-SNAPSHOT versions.
| `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

0 comments on commit f59b2c8

Please sign in to comment.