diff --git a/incubator/kafka/Chart.yaml b/incubator/kafka/Chart.yaml index 77250d37e6..da92b40027 100755 --- a/incubator/kafka/Chart.yaml +++ b/incubator/kafka/Chart.yaml @@ -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 diff --git a/incubator/kafka/README.md b/incubator/kafka/README.md index 3f381639f1..c9f3b9c4d8 100644 --- a/incubator/kafka/README.md +++ b/incubator/kafka/README.md @@ -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: diff --git a/incubator/kafka/templates/_helpers.tpl b/incubator/kafka/templates/_helpers.tpl index 602d0c69a6..03bfc0ace4 100644 --- a/incubator/kafka/templates/_helpers.tpl +++ b/incubator/kafka/templates/_helpers.tpl @@ -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 -}} diff --git a/incubator/kafka/templates/prometheusrules.yaml b/incubator/kafka/templates/prometheusrules.yaml new file mode 100644 index 0000000000..4f74ad5d05 --- /dev/null +++ b/incubator/kafka/templates/prometheusrules.yaml @@ -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 }} + diff --git a/incubator/kafka/templates/servicemonitors.yaml b/incubator/kafka/templates/servicemonitors.yaml index ea781cbfcc..6d35feb71c 100644 --- a/incubator/kafka/templates/servicemonitors.yaml +++ b/incubator/kafka/templates/servicemonitors.yaml @@ -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: diff --git a/incubator/kafka/values.yaml b/incubator/kafka/values.yaml index 0d1ec09dd9..f1e9664a79 100644 --- a/incubator/kafka/values.yaml +++ b/incubator/kafka/values.yaml @@ -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: