diff --git a/metricbeat/README.md b/metricbeat/README.md index 3920d88a9..6e83fb67f 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -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`" | `""` | @@ -142,4 +143,4 @@ To run the goss tests against the default example: ``` cd examples/default make goss -``` +``` \ No newline at end of file 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/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 c3c693033..db3022d8c 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -207,6 +207,27 @@ 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) + 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) + 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(): config = '' r = helm_template(config) 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