企业运维----Docker-kubernetes-监控(Helm prometheus部署)

21 篇文章 0 订阅
16 篇文章 0 订阅
本文介绍了使用Helm在Kubernetes环境中部署Prometheus进行监控的步骤,包括上传镜像、配置prometheus-operator、安装kube-state-metrics和prometheus-node-exporter,以及设置Grafana和Alertmanager的访问方式。
摘要由CSDN通过智能技术生成

kubernetes-监控


Helm prometheus部署

上传镜像请添加图片描述

拉取prometheus-operator

[root@server2 helm]# helm search repo prometheus-operator
NAME                       	CHART VERSION	APP VERSION	DESCRIPTION                                       
apphub/prometheus-operator 	8.7.0        	0.35.0     	Provides easy monitoring definitions for Kubern...
bitnami/prometheus-operator	0.31.1       	0.41.0     	DEPRECATED The Prometheus Operator for Kubernet...
[root@server2 helm]# helm pull apphub/prometheus-operator 
[root@server2 helm]# ls
bin                                 mychart-0.1.0.tgz
helm-push_0.9.0_linux_amd64.tar.gz  mychart-0.2.0.tgz
helm-v3.4.1-linux-amd64.tar.gz      nfs
kubeapps                            plugin.yaml
kubeapps-7.2.0.tgz                  LICENSE                             prometheus-operator-8.7.0.tgz
linux-amd64                         redis-cluster
metrics-server                      redis-cluster-6.3.2.tgz
mychart

解压到helm目录

[root@server2 helm]# tar zxf prometheus-operator-8.7.0.tgz 
[root@server2 helm]# ls
bin                                 mychart-0.1.0.tgz
helm-push_0.9.0_linux_amd64.tar.gz  mychart-0.2.0.tgz
helm-v3.4.1-linux-amd64.tar.gz      nfs
kubeapps                            plugin.yaml
kubeapps-7.2.0.tgz                  prometheus-operator
LICENSE                             prometheus-operator-8.7.0.tgz
linux-amd64                         redis-cluster
metrics-server                      redis-cluster-6.3.2.tgz
mychart

编辑配置文件

[root@server2 helm]# cd prometheus-operator/
[root@server2 prometheus-operator]# ls
Chart.lock  Chart.yaml       crds       requirements.lock  templates
charts      CONTRIBUTING.md  README.md  requirements.yaml  values.yaml
[root@server2 prometheus-operator]# vim values.yaml

 158     enabled: true
 166     hosts:
 167       - alertmanager.westos.org
 171     paths:
 172       - /
 248       repository: kubeapps/quay-alertmanager
 402   adminPassword: westos
 407     enabled: true
 424     hosts:
 425       - grafana.westos.org
 429     path: /
 992       repository: kubeapps/ghostunnel
1009         repository: kubeapps/kube-webhook-certgen
1178     repository: kubeapps/quay-prometheus-operator
1185     repository: kubeapps/quay-configmap-reload
1191     repository: kubeapps/quay-prometheus-config-reloader
1205     repository: kubeapps/k8s-gcr-hyperkube
1296     enabled: true
1305     hosts:
1306       - prometheus.westos.org
1310     paths:
1311       - /
1417       repository: kubeapps/quay-prometheus

grafana

[root@server2 prometheus-operator]# cd charts/
[root@server2 charts]# ls
grafana  kube-state-metrics  prometheus-node-exporter
[root@server2 charts]# cd grafana/
[root@server2 grafana]# vim values.yaml

 52   repository: kubeapps/grafana
 91   repository: kubeapps/curl
123   enabled: true
129   hosts:
130     - grafana.westos.org
209     repository: kubeapps/busybox
432   image: kubeapps/k8s-sidecar:0.1.20

kube-state-metrics和prometheus-node-exporter

[root@server2 grafana]# cd ..
[root@server2 charts]# cd kube-state-metrics/
[root@server2 kube-state-metrics]# vim values.yaml

  repository: kubeapps/quay-kube-state-metrics

[root@server2 kube-state-metrics]# cd ..
[root@server2 charts]# cd prometheus-node-exporter/
[root@server2 prometheus-node-exporter]# vim values.yaml

  repository: kubeapps/quay-node-exporter

添加一个ns并且安装prometheus-operator

[root@server2 prometheus-operator]# kubectl create namespace prometheus-operator
[root@server2 prometheus-operator]# helm install prometheus-operator . -n prometheus-operator 
[root@server2 prometheus-operator]# kubectl -n prometheus-operator get pod
NAME                                                     READY   STATUS    RESTARTS   AGE
alertmanager-prometheus-operator-alertmanager-0          2/2     Running   0          61m
prometheus-operator-grafana-7dff6d79d4-mxxfv             2/2     Running   0          68m
prometheus-operator-kube-state-metrics-f4459bb97-ztkjf   1/1     Running   0          68m
prometheus-operator-operator-7cd54fbdbd-hfbmb            2/2     Running   0          68m
prometheus-operator-prometheus-node-exporter-jrfbs       1/1     Running   1          21h
prometheus-operator-prometheus-node-exporter-zfb5t       1/1     Running   1          21h
prometheus-operator-prometheus-node-exporter-zgv44       1/1     Running   2          21h
prometheus-prometheus-operator-prometheus-0              3/3     Running   1          61m
[root@server2 prometheus-operator]# kubectl -n ingress-nginx get svc
NAME                                 TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.110.95.44    172.25.12.11   80:32341/TCP,443:31150/TCP   7d5h
ingress-nginx-controller-admission   ClusterIP      10.101.47.215   <none>         443/TCP                      7d5h

主机添加解析

[root@foundation12 ~]# vim /etc/hosts

 13 172.25.12.11 alertmanager.westos.org grafana.westos.org kubeapps.westos.    org www1.westos.org www2.westos.org prometheus.westos.org

访问http://prometheus.westos.org/
请添加图片描述
访问http://grafana.westos.org/
用户admin密码westos
进入grafana请添加图片描述
请添加图片描述
访问alertmanager.westos.org
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值