how to deploy blackbox on kubernetes1.19

  1. cat blackbox.yaml

    apiVersion: v1
    data:
      config.yml: |
        modules:
          http_2xx:
            prober: http
          tcp_connect:
            prober: tcp
    kind: ConfigMap
    metadata:
      name: blackbox
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: blackbox
    spec:
      replicas: 2
      selector:
        matchLabels:
          name: blackbox
      template:
        metadata:
          labels:
            name: blackbox
        spec:
          containers:
          - image: prom/blackbox-exporter
            name: blackbox
            ports:
            - containerPort: 9115
            volumeMounts:
            - name: config
              mountPath: /etc/blackbox_exporter
            args:
            - --config.file=/etc/blackbox_exporter/config.yml
            - --log.level=error
          volumes:
          - name: config
            configMap:
              name: blackbox
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: blackbox
    spec:
      selector:
        name: blackbox
      ports:
      - port: 9115
        targetPort: 9115
    
  2. cat prometheus.yaml

    - job_name: "blackbox"
      metrics_path: /probe
      params:
        module: [http_2xx]
      static_configs:
      - targets:
        - http://medatc-open:8080/actuator/health
        - http://medatc-qrcode:8905/actuator/health
      relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox:9115