|NO.Z.00328|——————————|CloudNative|——|KuberNetes&运维.V46|——|黑盒监控.v01|blackbox.v01|创建|

一、黑盒监控
### --- 黑盒监控和白盒监控模板

~~~     # 白盒监控:
~~~     监控一些内部的数据,topic的监控数据,Redis key的大小。
~~~     内部暴露的指标被称为白盒监控。#比较关注的是原因。
~~~     # 黑盒监控:
~~~     站在用户的角度看到的东西。网站不能打开,网站打开的比较慢。比较#关注现象,
~~~     表示正在发生的问题,正在发生的告警。
### --- 黑盒监控地址:

~~~     https://github.com/prometheus/blackbox_exporter

一、部署黑盒监控exporter:创建一个blackbox-conf-configmap.yaml
### --- 创建blackbox-configmap.yaml文件

[root@k8s-master01 blackbox]# vim blackbox-configmap.yaml
apiVersion: v1
data:
  blackbox.yml: |-
    modules:
      http_2xx:
        prober: http
      http_post_2xx:
        prober: http
        http:
          method: POST
      tcp_connect:
        prober: tcp
      pop3s_banner:
        prober: tcp
        tcp:
          query_response:
          - expect: "^+OK"
          tls: true
          tls_config:
            insecure_skip_verify: false
      ssh_banner:
        prober: tcp
        tcp:
          query_response:
          - expect: "^SSH-2.0-"
      irc_banner:
        prober: tcp
        tcp:
          query_response:
          - send: "NICK prober"
          - send: "USER prober prober prober :prober"
          - expect: "PING :([^ ]+)"
            send: "PONG ${1}"
          - expect: "^:[^ ]+ 001"
      icmp:
        prober: icmp
kind: ConfigMap
metadata:
  name: blackbox-conf
  namespace: monitoring
二、创建blackbox-conf.configmap
### --- 创建blackbox-config

[root@k8s-master01 blackbox]# kubectl create -f blackbox-configmap.yaml 
configmap/blackbox-conf created
### --- 查看创建结果

[root@k8s-master01 blackbox]# kubectl get cm -n monitoring
NAME                                                  DATA   AGE
blackbox-conf                                         1      39s
三、创建blackbox-conf-deployment.yaml
### --- 创建blackbox-deployment.yaml文件

[root@k8s-master01 blackbox]# vim blackbox-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    app: blackbox-exporter
  name: blackbox-exporter
  namespace: monitoring
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: blackbox-exporter
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: blackbox-exporter
    spec:
      containers:
      - args:
        - --config.file=/mnt/blackbox.yml
        env:
        - name: TZ
          value: Asia/Shanghai
        - name: LANG
          value: C.UTF-8
        image: prom/blackbox-exporter:master
        imagePullPolicy: IfNotPresent
        lifecycle: {}
        name: blackbox-exporter
        ports:
        - containerPort: 9115
          name: web
          protocol: TCP
        resources:
          limits:
            cpu: 324m
            memory: 443Mi
          requests:
            cpu: 10m
            memory: 10Mi
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          readOnlyRootFilesystem: false
          runAsNonRoot: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /usr/share/zoneinfo/Asia/Shanghai
          name: tz-config
        - mountPath: /etc/localtime
          name: tz-config
        - mountPath: /etc/timezone
          name: timezone
        - mountPath: /mnt
          name: config
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
          type: ""
        name: tz-config
      - hostPath:
          path: /etc/timezone
          type: ""
        name: timezone
      - configMap:
          defaultMode: 420
          name: blackbox-conf
        name: config
四、创建blackbox-conf-deployment
### --- 创建blackbox-deployment

[root@k8s-master01 blackbox]# kubectl create -f blackbox-deployment.yaml 
deployment.apps/blackbox-exporter created
### --- 查看blackbox-deployment创建结果

[root@k8s-master01 blackbox]# kubectl get po -n monitoring -owide
NAME                                   READY   STATUS    RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
blackbox-exporter-6f7955fbd6-9wsfr     1/1     Running   0          29s     172.27.14.228    k8s-node02     <none>           <none>
五、创建一个blackbox-conf-svc.yaml
### --- 创建blackbox-svc.yaml文件

[root@k8s-master01 blackbox]# vim blackbox-svc.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: blackbox-exporter
  name: blackbox-exporter
  namespace: monitoring
spec:
  ports:
  - name: container-1-web-1
    port: 9115
    protocol: TCP
    targetPort: 9115
  selector:
    app: blackbox-exporter
  sessionAffinity: None
  type: ClusterIP
六、创建blackbox-conf-svc
### --- 创建blackbox-svc

[root@k8s-master01 blackbox]# kubectl create -f blackbox-svc.yaml 
service/blackbox-exporter created
### --- 查看创建blackbox-svc.ep

[root@k8s-master01 blackbox]# kubectl get svc,ep -n monitoring
NAME                            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/blackbox-exporter       ClusterIP   10.105.13.82    <none>        9115/TCP                     24s
NAME                              ENDPOINTS                                                     AGE
endpoints/blackbox-exporter       172.27.14.228:9115                                            23s
七、查看创建结果是否有报错
### --- 查看日志是没有报错的

[root@k8s-master01 blackbox]# kubectl get po -n monitoring
NAME                                   READY   STATUS    RESTARTS   AGE
blackbox-exporter-6f7955fbd6-9wsfr     1/1     Running   0          5m54s
[root@k8s-master01 blackbox]# kubectl logs -f blackbox-exporter-6f7955fbd6-9wsfr -n monitoring
level=info ts=2021-05-28T06:34:10.939Z caller=main.go:385 msg="Listening on address" address=:9115
level=info ts=2021-05-28T06:34:10.940Z caller=tls_config.go:191 msg="TLS is disabled." http2=false
八、查看创建结果
### --- 查看创建结果

[root@k8s-master01 blackbox]# kubectl get cm -n monitoring
NAME                                                  DATA   AGE
blackbox-conf                                         1      12m
[root@k8s-master01 blackbox]# kubectl get po,svc,ep -n monitoring -l app=blackbox-exporter
NAME                                     READY   STATUS    RESTARTS   AGE
pod/blackbox-exporter-6f7955fbd6-9wsfr   1/1     Running   0          7m52s

NAME                        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
service/blackbox-exporter   ClusterIP   10.105.13.82   <none>        9115/TCP   5m59s

NAME                          ENDPOINTS            AGE
endpoints/blackbox-exporter   172.27.14.228:9115   5m58s

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(72)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示