blackbox黑盒监控部署(k8s内)tensuns专用

一、前言

部署在k8s中需要用到deployment、configmap、service服务

二、部署

创建存放yaml的目录

mkdir /opt/blackbox-exporter && cd /opt/blackbox-exporter

编辑blackbox配置文件,使用configmap挂在这

vi configmap.yaml

bash 复制代码
apiVersion: v1
kind: ConfigMap
metadata:
  name: blackbox-exporter
  namespace: monitor
  labels:
    app: blackbox-exporter
data:
  blackbox.yml: |-
    modules:
      http_2xx:
        prober: http
        http:
           valid_status_codes: [200,204]
           no_follow_redirects: false
           preferred_ip_protocol: ip4
           ip_protocol_fallback: false
      httpNoRedirect4ssl:
        prober: http
        http:
           valid_status_codes: [200,204,301,302,303]
           no_follow_redirects: true
           preferred_ip_protocol: ip4
           ip_protocol_fallback: false
      http200igssl:
        prober: http
        http:
           valid_status_codes:
           - 200
           tls_config:
             insecure_skip_verify: true

      http_4xx:
        prober: http
        http:
           valid_status_codes: [401,403,404]
           preferred_ip_protocol: ip4
           ip_protocol_fallback: false

      http_5xx:
        prober: http
        http:
           valid_status_codes: [500,502]
           preferred_ip_protocol: ip4
           ip_protocol_fallback: false

      http_post_2xx:
         prober: http
         http:
            method: POST

      icmp:
         prober: icmp

      tcp_connect:
         prober: tcp

      ssh_banner:
        prober: tcp
        tcp:
          query_response:
          - expect: "^SSH-2.0-"
          - send: "SSH-2.0-blackbox-ssh-check"

编辑deployment服务的yaml

vi deployment.yaml

bash 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: blackbox-exporter
  namespace: monitor
spec:
  replicas: 1
  selector:
    matchLabels:
      app: blackbox-exporter
  template:
    metadata:
      labels:
        app: blackbox-exporter
    spec:
      containers:
      - name: blackbox-exporter
        image: prom/blackbox-exporter:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9115
        readinessProbe:
          tcpSocket:
            port: 9115
          initialDelaySeconds: 10
          timeoutSeconds: 5
        resources:
          requests:
            memory: 50Mi
            cpu: 100m
          limits:
            memory: 60Mi
            cpu: 200m
        volumeMounts:
        - name: config
          mountPath: /etc/blackbox_exporter
        args:
        - '--config.file=/etc/blackbox_exporter/blackbox.yml'
        - '--web.listen-address=:9115'
      volumes:
      - name: config
        configMap:
          name: blackbox-exporter

编辑service服务的yaml

vi service.yaml

bash 复制代码
apiVersion: v1
kind: Service
metadata:
  labels:
    name: blackbox-exporter
  name: blackbox-exporter
  namespace: monitor
spec:
  ports:
    - name: blackbox-exporter
      protocol: TCP
      port: 9115
      targetPort: 9115
  selector:
    app: blackbox-exporter

创建命名空间

kubectl create namespace monitor

创建yaml文件对应服务

kubectl apply -f configmap.yaml

kubectl apply -f deployment.yaml

kubectl apply -f service.yaml

查看服务是否正常

kubectl get pod -n monitor

至此blackbox-exporter部署完成

相关推荐
tntlbb1 小时前
Ubuntu20.4 VPN+Docker代理配置
运维·ubuntu·docker·容器
Gabriel_liao2 小时前
Docker安装Neo4j
docker·容器·neo4j
有一个好名字2 小时前
zookeeper分布式锁模拟12306买票
分布式·zookeeper·云原生
Anna_Tong5 小时前
云原生大数据计算服务 MaxCompute 是什么?
大数据·阿里云·云原生·maxcompute·odps
豆豆豆豆变5 小时前
Docker轻量级可视化工具Portainer
docker·容器·自动化运维
花晓木5 小时前
k8s etcd 数据损坏处理方式
容器·kubernetes·etcd
运维&陈同学5 小时前
【模块一】kubernetes容器编排进阶实战之基于velero及minio实现etcd数据备份与恢复
数据库·后端·云原生·容器·kubernetes·etcd·minio·velero
花晓木5 小时前
k8s备份 ETCD , 使用velero工具进行备份
容器·kubernetes·etcd
大熊程序猿5 小时前
xxl-job docker 安装
运维·docker·容器
liuxuzxx8 小时前
Istio-2:流量治理之简单负载均衡
云原生·kubernetes·istio