[incubator/kafka] Add Prometheus Operator PrometheusRules (#20110)

* [incubator/kafka] Add Prometheus Operator PrometheusRules

Signed-off-by: Sam Weston <weston.sam@gmail.com>

* [incubator/kafka] Further README.md updates

Signed-off-by: Sam Weston <weston.sam@gmail.com>
This commit is contained in:
Sam Weston
2020-01-14 08:35:19 -08:00
committed by Kubernetes Prow Robot
parent 9402a760e5
commit 282bc9f8b4
6 changed files with 68 additions and 7 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v1
description: Apache Kafka is publish-subscribe messaging rethought as a distributed
commit log.
name: kafka
version: 0.20.7
version: 0.20.8
appVersion: 5.0.1
keywords:
- kafka
+7 -3
View File
@@ -126,9 +126,14 @@ following configurable parameters:
| `prometheus.kafka.affinity` | Defines affinities and anti-affinities for pods as defined in: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity preferences | `{}` |
| `prometheus.kafka.tolerations` | List of node tolerations for the pods. https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ | `[]` |
| `prometheus.operator.enabled` | True if using the Prometheus Operator, False if not | `false` |
| `prometheus.operator.serviceMonitor.namespace` | Namespace which Prometheus is running in. Default to kube-prometheus install. | `monitoring` |
| `prometheus.operator.serviceMonitor.releaseNamespace` | Set namespace to release namespace. Default false | `false` |
| `prometheus.operator.serviceMonitor.namespace` | Namespace in which to install the ServiceMonitor resource. Default to kube-prometheus install. | `monitoring` |
| `prometheus.operator.serviceMonitor.releaseNamespace` | Set namespace to release namespace. Default false | `false` |
| `prometheus.operator.serviceMonitor.selector` | Default to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install | `{ prometheus: kube-prometheus }` |
| `prometheus.operator.prometheusRule.enabled` | True to create a PrometheusRule resource for Prometheus Operator, False if not | `false` |
| `prometheus.operator.prometheusRule.namespace` | Namespace in which to install the PrometheusRule resource. Default to kube-prometheus install. | `monitoring` |
| `prometheus.operator.prometheusRule.releaseNamespace` | Set namespace to release namespace. Default false | `false` |
| `prometheus.operator.prometheusRule.selector` | Default to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install | `{ prometheus: kube-prometheus }` |
| `prometheus.operator.prometheusRule.rules` | Define the prometheus rules. See values file for examples | `{}` |
| `configJob.backoffLimit` | Number of retries before considering kafka-config job as failed | `6` |
| `topics` | List of topics to create & configure. Can specify name, partitions, replicationFactor, reassignPartitions, config. See values.yaml | `[]` (Empty list) |
| `zookeeper.enabled` | If True, installs Zookeeper Chart | `true` |
@@ -141,7 +146,6 @@ following configurable parameters:
| `zookeeper.affinity` | Defines affinities and anti-affinities for pods as defined in: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity preferences | `{}` |
| `zookeeper.nodeSelector` | Node labels for pod assignment | `{}` |
Specify parameters using `--set key=value[,key=value]` argument to `helm install`
Alternatively a YAML file that specifies the values for the parameters can be provided like this:
+8
View File
@@ -118,3 +118,11 @@ app.kubernetes.io/component: kafka-monitor
{{ .Values.prometheus.operator.serviceMonitor.namespace }}
{{- end -}}
{{- end -}}
{{- define "prometheusRule.namespace" -}}
{{- if .Values.prometheus.operator.prometheusRule.releaseNamespace -}}
{{ .Release.Namespace }}
{{- else -}}
{{ .Values.prometheus.operator.prometheusRule.namespace }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,16 @@
{{ if and .Values.prometheus.operator.enabled .Values.prometheus.operator.prometheusRule.enabled .Values.prometheus.operator.prometheusRule.rules }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "kafka.fullname" . }}
namespace: {{ include "serviceMonitor.namespace" . }}
labels:
{{- include "kafka.monitor.labels" . | nindent 4 }}
{{- toYaml .Values.prometheus.operator.prometheusRule.selector | nindent 4 }}
spec:
groups:
- name: {{ include "kafka.fullname" . }}
rules:
{{- toYaml .Values.prometheus.operator.prometheusRule.rules | nindent 6 }}
{{- end }}
@@ -6,7 +6,7 @@ metadata:
namespace: {{ include "serviceMonitor.namespace" . }}
labels:
{{- include "kafka.monitor.labels" . | nindent 4 }}
{{ toYaml .Values.prometheus.operator.serviceMonitor.selector | indent 4 }}
{{- toYaml .Values.prometheus.operator.serviceMonitor.selector | nindent 4 }}
spec:
selector:
matchLabels:
@@ -30,7 +30,7 @@ metadata:
namespace: {{ include "serviceMonitor.namespace" . }}
labels:
{{- include "kafka.monitor.labels" . | nindent 4 }}
{{ toYaml .Values.prometheus.operator.serviceMonitor.selector | indent 4 }}
{{ toYaml .Values.prometheus.operator.serviceMonitor.selector | nindent 4 }}
spec:
selector:
matchLabels:
+34 -1
View File
@@ -368,7 +368,7 @@ prometheus:
enabled: false
serviceMonitor:
# Namespace Prometheus is installed in
# Namespace in which to install the ServiceMonitor resource.
namespace: monitoring
# Use release namespace instead
releaseNamespace: false
@@ -379,6 +379,39 @@ prometheus:
selector:
prometheus: kube-prometheus
prometheusRule:
## Add Prometheus Rules?
enabled: false
## Namespace in which to install the PrometheusRule resource.
namespace: monitoring
# Use release namespace instead
releaseNamespace: false
## Defaults to whats used if you follow CoreOS [Prometheus Install Instructions](https://github.com/coreos/prometheus-operator/tree/master/helm#tldr)
## [Prometheus Selector Label](https://github.com/coreos/prometheus-operator/blob/master/helm/prometheus/templates/prometheus.yaml#L65)
## [Kube Prometheus Selector Label](https://github.com/coreos/prometheus-operator/blob/master/helm/kube-prometheus/values.yaml#L298)
selector:
prometheus: kube-prometheus
## Some example rules.
## e.g. max(kafka_controller_kafkacontroller_activecontrollercount_value{service="my-kafka-release"}) by (service) < 1
rules:
- alert: KafkaNoActiveControllers
annotations:
message: The number of active controllers in {{ "{{" }} $labels.namespace {{ "}}" }} is less than 1. This usually means that some of the Kafka nodes aren't communicating properly. If it doesn't resolve itself you can try killing the pods (one by one whilst monitoring the under-replicated partitions graph).
expr: max(kafka_controller_kafkacontroller_activecontrollercount_value) by (namespace) < 1
for: 5m
labels:
severity: critical
- alert: KafkaMultipleActiveControllers
annotations:
message: The number of active controllers in {{ "{{" }} $labels.namespace {{ "}}" }} is greater than 1. This usually means that some of the Kafka nodes aren't communicating properly. If it doesn't resolve itself you can try killing the pods (one by one whilst monitoring the under-replicated partitions graph).
expr: max(kafka_controller_kafkacontroller_activecontrollercount_value) by (namespace) > 1
for: 5m
labels:
severity: critical
## Kafka Config job configuration
##
configJob: