prometheus-07k8s-coredns

阅读量: zyh 2021-06-18 16:06:01
Categories: > Tags:

检查 metrics 接口

➜   kubectl describe cm coredns -n kube-system
Name:         coredns
Namespace:    kube-system
Labels:       <none>
Annotations:  <none>

Data
====
Corefile:
----
.:53 {
    errors
    health {
       lameduck 5s
    }
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
       pods insecure
       fallthrough in-addr.arpa ip6.arpa
       ttl 30
    }
    prometheus :9153
    forward . /etc/resolv.conf {
       max_concurrent 1000
    }
    cache 30
    loop
    reload
    loadbalance
}

Events:  <none>

prometheus :9153 表示开启

确认 coredns 的 pod 地址

➜   kubectl get pod -n kube-system -o wide | grep coredns
coredns-78fcd69978-dt4lx          1/1     Running   1 (34d ago)    121d   10.97.0.195     k8s01   <none>           <none>
coredns-78fcd69978-nzb7m          1/1     Running   1 (34d ago)    121d   10.97.0.183     k8s01   <none>           <none>

添加抓取配置

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
  namespace: monitor
data:
  prometheus.yml: |
    global:
      scrape_interval: 15s
      scrape_timeout: 15s
    scrape_configs:
    - job_name: 'prometheus'
      static_configs:
      - targets: ['localhost:9090']
    - job_name: 'coredns'
      static_configs:
      - targets: ['10.97.0.195:9153', '10.97.0.183:9153']

重载prometheus

curl -X POST http://prometheus_ip:9090/-/reload