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

相关推荐
福大大架构师每日一题8 小时前
22.1 k8s不同role级别的服务发现
容器·kubernetes·服务发现
莹雨潇潇8 小时前
Docker 快速入门(Ubuntu版)
java·前端·docker·容器
weixin_453965009 小时前
[单master节点k8s部署]30.ceph分布式存储(一)
分布式·ceph·kubernetes
weixin_453965009 小时前
[单master节点k8s部署]32.ceph分布式存储(三)
分布式·ceph·kubernetes
tangdou3690986559 小时前
1分钟搞懂K8S中的NodeSelector
云原生·容器·kubernetes
Lansonli10 小时前
云原生(四十一) | 阿里云ECS服务器介绍
服务器·阿里云·云原生
Dylanioucn11 小时前
【分布式微服务云原生】掌握分布式缓存:Redis与Memcached的深入解析与实战指南
分布式·缓存·云原生
tangdou36909865512 小时前
Docker系列-5种方案超详细讲解docker数据存储持久化(volume,bind mounts,NFS等)
docker·容器
later_rql12 小时前
k8s-集群部署1
云原生·容器·kubernetes
weixin_4539650015 小时前
[单master节点k8s部署]31.ceph分布式存储(二)
分布式·ceph·kubernetes