From cf5f14c6c66a0ed698f83a38a118e4ef3065ab54 Mon Sep 17 00:00:00 2001 From: Gabriele Diener Date: Thu, 9 Jan 2020 15:59:30 +0100 Subject: [PATCH 1/5] [metricbeat] Add priorityClassName config --- metricbeat/templates/daemonset.yaml | 3 +++ metricbeat/values.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 7fb1cfdf7..60917202e 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -44,6 +44,9 @@ spec: {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} + {{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName }} + {{- end }} {{- with .Values.affinity }} affinity: {{ toYaml . | nindent 8 -}} {{- end }} diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 5999ceb9f..efabef1ac 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -180,6 +180,10 @@ nodeSelector: {} affinity: {} +# This is the PriorityClass settings as defined in +# https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass +priorityClassName: "" + updateStrategy: RollingUpdate # Override various naming aspects of this chart From 3bc1e4a8787d0af5af5c33124cd7a4426888f625 Mon Sep 17 00:00:00 2001 From: Gabriele Diener Date: Thu, 9 Jan 2020 16:00:23 +0100 Subject: [PATCH 2/5] [metricbeat] add doc for priorityClassName --- metricbeat/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metricbeat/README.md b/metricbeat/README.md index 7ee006b73..3e99c496c 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -71,7 +71,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.1 | `extraEnvs` | Extra [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config) which will be appended to the `env:` definition for the container | `[]` | | `extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function | `""` | | `extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function | `""` | -| `envFrom` | Templatable string of envFrom to be passed to the [environment from variables](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables) which will be appended to the `envFrom:` definition for the container | `[]` +| `envFrom` | Templatable string of envFrom to be passed to the [environment from variables](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables) which will be appended to the `envFrom:` definition for the container | `[]` | `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Metricbeat registry data | `/var/lib` | | `image` | The Metricbeat docker image | `docker.elastic.co/beats/metricbeat` | | `imageTag` | The Metricbeat docker image tag | `7.5.1` | @@ -92,6 +92,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.1 | `nodeSelector` | Configurable [nodeSelector](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) | `{}` | | `affinity` | Configurable [affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) | `{}` | | `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) for the `DaemonSet`. By default Kubernetes will kill and recreate pods on updates. Setting this to `OnDelete` will require that pods be deleted manually. | `RollingUpdate` | +| `priorityClassName` | The [name of the PriorityClass](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass). No default is supplied as the PriorityClass must be created first. | `""` | | `replicas` | The replica count for the metricbeat deployment talking to kube-state-metrics | `1` | | `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` | From 499e887fc735f300298dc60d5a3d09a366646b8c Mon Sep 17 00:00:00 2001 From: Gabriele Diener Date: Thu, 9 Jan 2020 16:00:34 +0100 Subject: [PATCH 3/5] [metricbeat] add test for priorityClassName --- metricbeat/tests/metricbeat_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index c3c693033..e78ecfc1a 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -207,6 +207,22 @@ def test_adding_an_affinity_rule(): assert r['daemonset'][name]['spec']['template']['spec']['affinity']['podAntiAffinity'][ 'requiredDuringSchedulingIgnoredDuringExecution'][0]['topologyKey'] == 'kubernetes.io/hostname' + +def test_priority_class_name(): + config = ''' +priorityClassName: "" +''' + r = helm_template(config) + spec = r['daemonset'][name]['spec']['template']['spec'] + assert 'priorityClassName' not in spec + + config = ''' +priorityClassName: "highest" +''' + r = helm_template(config) + priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName'] + assert priority_class_name == "highest" + def test_cluster_role_rules(): config = '' r = helm_template(config) From c6a5ab197a11002fe61d2dfec5d9d5f19d225d42 Mon Sep 17 00:00:00 2001 From: Gabriele Diener Date: Sun, 12 Jan 2020 11:23:11 +0100 Subject: [PATCH 4/5] [metricbeat] typo --- metricbeat/tests/metricbeat_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index e78ecfc1a..8768118fe 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -223,6 +223,7 @@ def test_priority_class_name(): priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName'] assert priority_class_name == "highest" + def test_cluster_role_rules(): config = '' r = helm_template(config) From e5a9376c2ae8592239af3fe2c09a7cd6dc545119 Mon Sep 17 00:00:00 2001 From: Gabriele Diener Date: Mon, 20 Jan 2020 13:00:48 +0100 Subject: [PATCH 5/5] added priorityClassName in metrics deployment --- metricbeat/templates/deployment.yaml | 3 +++ metricbeat/tests/metricbeat_test.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index 0a772c453..d1203427a 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -35,6 +35,9 @@ spec: {{- with .Values.tolerations }} tolerations: {{ toYaml . | indent 6 }} + {{- end }} + {{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName }} {{- end }} serviceAccountName: {{ template "metricbeat.serviceAccount" . }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }} diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index 8768118fe..db3022d8c 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -213,15 +213,19 @@ def test_priority_class_name(): priorityClassName: "" ''' r = helm_template(config) - spec = r['daemonset'][name]['spec']['template']['spec'] - assert 'priorityClassName' not in spec + daemonset_spec = r['daemonset'][name]['spec']['template']['spec'] + deployment_spec = r['deployment'][name + '-metrics']['spec']['template']['spec'] + assert 'priorityClassName' not in daemonset_spec + assert 'priorityClassName' not in deployment_spec config = ''' priorityClassName: "highest" ''' r = helm_template(config) - priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName'] - assert priority_class_name == "highest" + daemonset_priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName'] + deployment_priority_class_name = r['deployment'][name + '-metrics']['spec']['template']['spec']['priorityClassName'] + assert daemonset_priority_class_name == "highest" + assert deployment_priority_class_name == "highest" def test_cluster_role_rules():