前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Kubernetes 1.19.0——部署prometheus监控

Kubernetes 1.19.0——部署prometheus监控

原创
作者头像
gz_naldo
修改2020-11-09 10:37:10
2.3K1
修改2020-11-09 10:37:10
举报
文章被收录于专栏:CloudComputing

普罗米修斯架构

exporter 是用来收集数据的,要监测不同的东西,就需要有不同的 exporter。比如要监测

mysql,需要创建一个 mysql 的 exporter,要监测 pod 则需要 pod 的 exporter,要监测

kube-proxy 则需要一个 kube-proxy 的 exporter 等等。

先下载pull ali/prometheus-operator,然后解压
先下载pull ali/prometheus-operator,然后解压
在当前目录安装并等待状态running
在当前目录安装并等待状态running
代码语言:javascript
复制
[root@vms61 prometheus-operator]# helm ls
NAME    NAMESPACE       REVISION        UPDATED STATUS  CHART   APP VERSION
[root@vms61 prometheus-operator]# helm install mon .
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
NAME: mon
LAST DEPLOYED: Sat Oct 17 13:59:52 2020
NAMESPACE: chap11-helm
STATUS: deployed
REVISION: 1
NOTES:
The Prometheus Operator has been installed. Check its status by running:
  kubectl --namespace chap11-helm get pods -l "release=mon"
Visit https://github.com/coreos/prometheus-operator for instructions on how
to create & configure Alertmanager and Prometheus instances using the Operator.
[root@vms61 prometheus-operator]# kubectl get pods
NAME                                                  READY   STATUS              RESTARTS   AGE
alertmanager-mon-prometheus-operator-alertmanager-0   0/2     ContainerCreating   0          15s
mon-grafana-f9bfc447d-7s9bb                           0/2     PodInitializing     0          41s
mon-kube-state-metrics-568976749-4rwsc                1/1     Running             0          41s
mon-prometheus-node-exporter-bmjhn                    1/1     Running             0          41s
mon-prometheus-node-exporter-d2tj8                    1/1     Running             0          41s
mon-prometheus-node-exporter-hz7gz                    1/1     Running             0          41s
mon-prometheus-operator-operator-f5d8c8b49-dnhct      2/2     Running             0          41s
prometheus-mon-prometheus-operator-prometheus-0       0/3     ContainerCreating   0          5s
[root@vms61 prometheus-operator]# kubectl get pods
NAME                                                  READY   STATUS    RESTARTS   AGE
alertmanager-mon-prometheus-operator-alertmanager-0   2/2     Running   0          4m43s
mon-grafana-f9bfc447d-7s9bb                           2/2     Running   0          5m9s
mon-kube-state-metrics-568976749-4rwsc                1/1     Running   0          5m9s
mon-prometheus-node-exporter-bmjhn                    1/1     Running   0          5m9s
mon-prometheus-node-exporter-d2tj8                    1/1     Running   0          5m9s
mon-prometheus-node-exporter-hz7gz                    1/1     Running   0          5m9s
mon-prometheus-operator-operator-f5d8c8b49-dnhct      2/2     Running   0          5m9s
prometheus-mon-prometheus-operator-prometheus-0       3/3     Running   1          4m33s

将mon-grafana中的type配置改成NodePort
将mon-grafana中的type配置改成NodePort
代码语言:javascript
复制
[root@vms61 prometheus-operator]# kubectl get svc
NAME                                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
alertmanager-operated                  ClusterIP   None             <none>        9093/TCP,9094/TCP,9094/UDP   5m54s
mon-grafana                            ClusterIP   10.104.98.81     <none>        80/TCP                       6m21s
mon-kube-state-metrics                 ClusterIP   10.106.52.226    <none>        8080/TCP                     6m20s
mon-prometheus-node-exporter           ClusterIP   10.101.70.99     <none>        9100/TCP                     6m20s
mon-prometheus-operator-alertmanager   ClusterIP   10.101.189.189   <none>        9093/TCP                     6m20s
mon-prometheus-operator-operator       ClusterIP   10.100.215.55    <none>        8080/TCP,443/TCP             6m21s
mon-prometheus-operator-prometheus     ClusterIP   10.105.9.119     <none>        9090/TCP                     6m21s
prometheus-operated                    ClusterIP   None             <none>        9090/TCP                     5m44s
[root@vms61 prometheus-operator]# kubectl edit svc mon-grafana
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
  annotations:
    meta.helm.sh/release-name: mon
    meta.helm.sh/release-namespace: chap11-helm
  creationTimestamp: "2020-10-17T06:00:14Z"
  labels:
    app: grafana
    app.kubernetes.io/managed-by: Helm
    chart: grafana-4.3.0
    heritage: Helm
    release: mon
  name: mon-grafana
  namespace: chap11-helm
  resourceVersion: "830868"
  selfLink: /api/v1/namespaces/chap11-helm/services/mon-grafana
  uid: 360e9f2b-ba84-4409-9aa9-be6027be1f36
spec:
  clusterIP: 10.104.98.81
  ports:
  - name: service
    port: 80
    protocol: TCP
    targetPort: 3000
  selector:
    app: grafana
    release: mon
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

修改成功,可通过物理机的30380访问grafana
修改成功,可通过物理机的30380访问grafana
访问成功
访问成功

那么账号密码怎么查看呢?

账号和密码都是base64编码后的值
账号和密码都是base64编码后的值
代码语言:javascript
复制
[root@vms61 prometheus-operator]# kubectl get sa
NAME                                   SECRETS   AGE
default                                1         2d2h
mon-grafana                            1         11m
mon-grafana-test                       1         11m
mon-kube-state-metrics                 1         11m
mon-prometheus-node-exporter           1         11m
mon-prometheus-operator-alertmanager   1         11m
mon-prometheus-operator-operator       1         11m
mon-prometheus-operator-prometheus     1         11m
[root@vms61 prometheus-operator]# kubectl get secrets mon-grafana -o yaml

代码语言:javascript
复制
[root@vms61 prometheus-operator]# echo YWRtaW4= | base64 -d
admin
[root@vms61 prometheus-operator]# echo cHJvbS1vcGVyYXRvcg== | base64 -d
prom-operator

登录成功
登录成功

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 普罗米修斯架构
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档