kube-prometheus icon indicating copy to clipboard operation
kube-prometheus copied to clipboard

https://kubernetes.default.svc:443 Unable to Probes monitor issues

Open erictarrence opened this issue 3 years ago • 5 comments

kube-prometheus version:0.10.0

How to use probes to monitor k8s apiserver url https://kubernetes.default.svc:443

I customized the https_2xx monitoring type and defined https://kubernetes.default.svc:443 monitoring using Probe, But it doesn't take effect, How can I set up to monitor https://kubernetes.default.svc:443

kubectl -n monitoring get pod | grep blackbox blackbox-exporter-6798fb5bb4-pbwwt** 3/3 Running 4 2d7h

kubectl -n monitoring edit cm blackbox-exporter-configuration

  "https_2xx":
    "http":
      "method": "GET"
      "tls_config": 
        "ca_file": "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
      "bearer_token_file": "/var/run/secrets/kubernetes.io/serviceaccount/token"
      "preferred_ip_protocol": "ip4"
    "prober": "http"

cat blackbox-probe-https.yaml

apiVersion: monitoring.coreos.com/v1
kind: Probe
metadata:
  labels:
    app.kubernetes.io/component: exporter
    app.kubernetes.io/name: blackbox-exporter
    app.kubernetes.io/part-of: kube-prometheus
    app.kubernetes.io/version: 0.19.0
  name: blackbox-https
  namespace: monitoring
spec:
  module: https_2xx
  prober:
    url: blackbox-exporter.monitoring.svc:19115
  targets:
    staticConfig:
      static:
      - https://192.168.1.254:6444
      - https://192.168.1.254:6443
      - https://kubernetes.default.svc:443

erictarrence avatar Jan 22 '22 12:01 erictarrence

When you say it doesn't take effect, what do you mean exactly? Is it that you are not seeing the configuration applied, or the target is down etc?

I wasn't able to reproduce and the probe is successful using the following steps:

Add the following snippet to the ConfigMap

      "http_k8s":
        "prober": "http"
        "timeout": "5s"
        "http":
          "bearer_token": "/var/run/secrets/kubernetes.io/serviceaccount/token"
          "tls_config":
            "ca_file": "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"

Rollout the Deployment:

kubectl -n monitoring rollout restart deployment blackbox-exporter

Add the following Probe

apiVersion: monitoring.coreos.com/v1
kind: Probe
metadata:
  labels:
    app.kubernetes.io/component: exporter
    app.kubernetes.io/name: blackbox-exporter
    app.kubernetes.io/part-of: kube-prometheus
    app.kubernetes.io/version: 0.19.0
  name: blackbox-https
  namespace: monitoring
spec:
  module: http_k8s
  prober:
    url: blackbox-exporter.monitoring.svc:19115
  targets:
    staticConfig:
      static:
      - https://kubernetes.default.svc:443

Observe targets up and successful probe: Screenshot 2022-02-10 at 12 00 12 Screenshot 2022-02-10 at 11 57 25

philipgough avatar Feb 10 '22 12:02 philipgough

@PhilipGough Thanks,I followed your method and configmap/probe configuration, But the prometheus alert prompts that the website instance https://kubernetes.default.svc:443 cannot be linked,State is FIRING

For specific error information, see picture

截屏2022-02-16 20 44 00

erictarrence avatar Feb 16 '22 12:02 erictarrence

Why in the first place you are using blackbox_exporter to probe kubernetes API server? Default kube-prometheus setup already covers monitoring of k8s API.

paulfantom avatar Feb 17 '22 09:02 paulfantom

Why in the first place you are using blackbox_exporter to probe kubernetes API server? Default kube-prometheus setup already covers monitoring of k8s API.

I'mWant to monitor kubernetes API SSL certificate expiration time

erictarrence avatar Feb 24 '22 04:02 erictarrence

This issue has been automatically marked as stale because it has not had any activity in the last 60 days. Thank you for your contributions.

github-actions[bot] avatar Apr 26 '22 03:04 github-actions[bot]

This issue was closed because it has not had any activity in the last 120 days. Please reopen if you feel this is still valid.

github-actions[bot] avatar Aug 24 '22 03:08 github-actions[bot]