diff --git a/apm-server/README.md b/apm-server/README.md index 2e039bd6a..b7e1f67b6 100644 --- a/apm-server/README.md +++ b/apm-server/README.md @@ -89,7 +89,7 @@ as a reference. They are also used in the automated testing of this chart. |-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| | `affinity` | Configurable [affinity][] | `{}` | | `apmConfig` | Allows you to add any config files in `/usr/share/apm-server/config` such as `apm-server.yml` | see [values.yaml][] | -| `autoscaling` | Enable the [horizontal pod autoscaler][] | `enabled: false` | +| `autoscaling` | Enable the [horizontal pod autoscaler][] | see [values.yaml][] | | `envFrom` | Templatable string to be passed to the [environment from variables][] which will be appended to the `envFrom:` definition for the container | `[]` | | `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | | `extraEnvs` | Extra [environment variables][] which will be appended to the `env:` definition for the container | `[]` | diff --git a/apm-server/templates/hpa.yaml b/apm-server/templates/hpa.yaml index a254adb09..b78724124 100644 --- a/apm-server/templates/hpa.yaml +++ b/apm-server/templates/hpa.yaml @@ -14,4 +14,13 @@ spec: apiVersion: apps/v1 kind: Deployment name: {{ template "apm.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.averageCpuUtilization }} {{- end }} diff --git a/apm-server/tests/apmserver_test.py b/apm-server/tests/apmserver_test.py index 2ce3b70b1..a3b1419df 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -341,3 +341,13 @@ def test_setting_fullnameOverride(): ] == project ) + + +def test_enabling_horizontal_pod_autoscaler(): + config = """ +autoscaling: + enabled: true +""" + r = helm_template(config) + + assert "horizontalpodautoscaler" in r diff --git a/apm-server/values.yaml b/apm-server/values.yaml index 07657e14d..0d3d3326a 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -140,6 +140,9 @@ fullnameOverride: "" autoscaling: enabled: false + minReplicas: 1 + maxReplicas: 3 + averageCpuUtilization: 50 ingress: enabled: false