我想在 kube-system 命名空间中使用 Prometheus 废弃默认 kubelet 和指标服务器中的指标。我怎样才能做到这一点?
我尝试使用此配置,但没有成功。我有:获取“https://InternalIP:443/metrics”:拨打tcp:在10.96.128.2:53上查找InternalIP:没有这样的主机。
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |
global:
scrape_interval: 1s
scrape_configs:
- job_name: metrics-server
scheme: https
static_configs:
- targets: [metrics-server]
请帮忙,我已经尝试了很多。 谢谢:)
根据 Prometheus 文档,您应该在 configmap 数据中包含主机的端口号,如下所示:
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |
global:
scrape_interval: 1s
scrape_configs:
- job_name: metrics-server
scheme: https
static_configs:
- targets: [metrics-server:8080]
## check the service port number of the kube state metrics server
或者,[此解决方案}(如何将指标服务器抓取到 kubernetes 集群外部的 prometheus)将需要您在 kube 状态指标部署上添加注释:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.10.0
name: kube-state-metrics
namespace: kube-system
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'port'
prometheus.io/path: '/metrics'
prometheus.io/scheme: 'http'