这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
执行kubectl apply -f kafka-metrics.yaml,这里面包含了Exporter(用于暴露指标),文件kafka-metrics.yaml可以在GitHub的发布包中找到
执行以下命令,生成名为prometheus-operator-deployment.yaml的文件
curl -s https://raw.githubusercontent.com/coreos/prometheus-operator/master/bundle.yaml | sed -e '/[[:space:]]*namespace: [a-zA-Z0-9-]*$/s/namespace:[[:space:]]*[a-zA-Z0-9-]*$/namespace: my-namespace/' > prometheus-operator-deployment.yaml
sed -i 's/namespace: .*/namespace: my-namespace/' prometheus.yaml
kubectl apply -f prometheus-additional.yaml
kubectl apply -f strimzi-pod-monitor.yaml
kubectl apply -f prometheus-rules.yaml
kubectl apply -f prometheus.yaml
kubectl apply -f grafana.yaml
kubectl create namespace aabbcc
kubectl create -f 'https://strimzi.io/install/latest?namespace=aabbcc' -n aabbcc
kubectl create -f 'https://gitee.com/zq2599/blog_download_files/raw/master/strimzi/prometheus/kafka-metrics.yaml?namespace=aabbcc' -n aabbcc
curl –connect-timeout 300 -m 300 -s https://raw.githubusercontent.com/coreos/prometheus-operator/master/bundle.yaml | sed -e '/[[:space:]]*namespace: [a-zA-Z0-9-]*$/s/namespace:[[:space:]]*[a-zA-Z0-9-]*$/namespace: aabbcc/' > prometheus-operator-deployment.yaml
curl -s https://gitee.com/zq2599/blog_download_files/raw/master/strimzi/prometheus/prometheus.yaml | sed -e 's/namespace: .*/namespace: aabbcc/' > prometheus.yaml
wget https://gitee.com/zq2599/blog_download_files/raw/master/strimzi/prometheus/prometheus-additional.yaml
wget https://gitee.com/zq2599/blog_download_files/raw/master/strimzi/prometheus/prometheus-rules.yaml
wget https://gitee.com/zq2599/blog_download_files/raw/master/strimzi/prometheus/grafana.yaml
编号 | 文件名 | 作用 | 是否需要修改 |
---|---|---|---|
1 | prometheus-operator-deployment.yaml | 创建prometheus-operator | 是 |
2 | prometheus.yaml | 创建prometheus | 是 |
3 | strimzi-pod-monitor.yaml | prometheus采集pod指标的规则 | 是 |
4 | prometheus-additional.yaml | 可以在此增加prometheus的采集job | 否 |
5 | prometheus-rules.yaml | 告警规则 | 否 |
6 | grafana.yaml | 创建grafana | 否 |
7 | grafana-service-nodeport.yaml | grafana的服务配置文件,端口是31330 | 否 |
kubectl create -f prometheus-operator-deployment.yaml
kubectl apply -f prometheus-additional.yaml
kubectl apply -f strimzi-pod-monitor.yaml
kubectl apply -f prometheus-rules.yaml
kubectl apply -f prometheus.yaml
kubectl apply -f grafana.yaml
kubectl create clusterrolebinding kube-state-metrics-admin-binding \
--clusterrole=cluster-admin \
--user=system:serviceaccount:default:prometheus-server
kubectl apply -f grafana-service-nodeport.yaml
kubectl -n aabbcc \
run kafka-producer \
-ti \
--image=quay.io/strimzi/kafka:0.32.0-kafka-3.3.1 \
--rm=true \
--restart=Never \
-- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic
kubectl -n aabbcc \
run kafka-consumer \
-ti \
--image=quay.io/strimzi/kafka:0.32.0-kafka-3.3.1 \
--rm=true \
--restart=Never \
-- bin/kafka-console-consumer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic --from-beginning
除了strimzi提供的grafana图表,我们还可以使用grabana官网上的kafka图标,最具代表性的应该是Kafka Exporter Overview,导入方法很简单,如下图,在导入表单上输入ID号7589即可(记得点击Load按钮,数据源继续选prometheus)
此dashboard的效果如下
至此,strimzi中部署监控的实战已经完成,希望本篇能给您一些参考,助您顺利完成部署,欢迎您继续关注《strimzi实战》系列,接下来会解锁更多strimzi的神奇能力