From 2cc10d00804711a8331dcb9d0b8fa274a43f34a9 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:11:37 +0100 Subject: [PATCH] [6.8] [apm-server] Add option loadBalancerIP to service (#1075) (#1092) Co-authored-by: Thomas Decaux --- apm-server/templates/service.yaml | 7 +++++++ apm-server/tests/apmserver_test.py | 14 ++++++++++++++ apm-server/values.yaml | 1 + 3 files changed, 22 insertions(+) diff --git a/apm-server/templates/service.yaml b/apm-server/templates/service.yaml index 09b8d19e0..f569cb19e 100644 --- a/apm-server/templates/service.yaml +++ b/apm-server/templates/service.yaml @@ -13,6 +13,13 @@ metadata: {{- end }} spec: type: {{ .Values.service.type }} +{{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} +{{- end }} +{{- with .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml . | indent 4 }} +{{- end }} ports: - port: {{ .Values.service.port }} {{- with .Values.service.nodePort }} diff --git a/apm-server/tests/apmserver_test.py b/apm-server/tests/apmserver_test.py index c86a5348d..d60007f3e 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -26,6 +26,9 @@ def test_defaults(): assert c["image"].startswith("docker.elastic.co/apm/apm-server:") assert c["ports"][0]["containerPort"] == 8200 + # Make sure that the default 'loadBalancerIP' string is empty + assert "loadBalancerIP" not in r["service"][name]["spec"] + assert "hostAliases" not in r["deployment"][name]["spec"]["template"]["spec"] @@ -376,3 +379,14 @@ def test_hostaliases(): r = helm_template(config) hostAliases = r["deployment"][name]["spec"]["template"]["spec"]["hostAliases"] assert {"ip": "127.0.0.1", "hostnames": ["foo.local", "bar.local"]} in hostAliases + + +def test_adding_loadBalancerIP(): + config = """ + service: + loadBalancerIP: 12.5.11.79 + """ + + r = helm_template(config) + + assert r["service"][name]["spec"]["loadBalancerIP"] == "12.5.11.79" diff --git a/apm-server/values.yaml b/apm-server/values.yaml index a2704b8e0..323560baa 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -172,6 +172,7 @@ ingress: service: type: ClusterIP + loadBalancerIP: "" port: 8200 nodePort: "" annotations: {}