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部署完成

相关推荐
小袁搬码2 小时前
Windows中指定路径安装DockerDesktop
windows·docker·容器·docker desktop
qq_312920112 小时前
docker 部署 kvm 图形化管理工具 WebVirtMgr
运维·docker·容器
踏雪Vernon2 小时前
[OpenHarmony5.0][Docker][环境]OpenHarmony5.0 Docker编译环境镜像下载以及使用方式
linux·docker·容器·harmonyos
条纹布鲁斯3 小时前
dockerdsktop修改安装路径/k8s部署wordpress和ubuntu
docker·kubernetes
CP-DD5 小时前
Docker 容器化开发 应用
运维·docker·容器
老司机张师傅6 小时前
【微服务实战之Docker容器】第七章-Dockerfile解析
容器·dockerfile·虚悬镜像·docker学习
登云时刻7 小时前
Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(一)
redis·kubernetes·bootstrap
运维&陈同学7 小时前
【zookeeper03】消息队列与微服务之zookeeper集群部署
linux·微服务·zookeeper·云原生·消息队列·云计算·java-zookeeper
吴半杯7 小时前
gateway漏洞(CVE-2022-22947)
docker·kubernetes·gateway
Code_Artist10 小时前
使用Portainer来管理并编排Docker容器
docker·云原生·容器