prometheus 监控pod 提示context deadline exceeded错误
我用二进制跑的k8s和prometheus,然后在prometheu.yml
配置。
- job_name: 'kubernetes-service-endpoints'
scheme: https
kubernetes_sd_configs:
- role: endpoints
api_server: https://192.168.3.17:6443/
tls_config:
insecure_skip_verify: true
bearer_token: "**********************"
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: kubernetes_name
- source_labels: [__meta_kubernetes_pod_node_name]
action: replace
target_label: kubernetes_node
pod的yaml文件,这是一个简单的nginx服务:
apiVersion: v1
kind: Service
metadata:
name: rrjc-algorithm
namespace: default
annotations: # 在metadata下增加annotations
prometheus.io/scrape: 'true' # 开启K8s动态监测后端pod数据
## prometheus.io/path: '/metrics' #pod暴露的/metrics接口地址
prometheus.io/port: '9163' #pod暴露的采集数据端口
spec:
selector:
app: rrjc-algorithm
release: canary
ports:
- name: http
port: 8081
targetPort: 80
nodePort: 30001
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: algorithm-deploy
spec:
replicas: 3
selector:
matchLabels:
app: rrjc-algorithm
release: canary
template:
metadata:
labels:
app: rrjc-algorithm
release: canary
spec:
containers:
- name: rrjc-algorithm
image: ****.****.com/rrjc/httpd
ports:
- name: httpd
containerPort: 80
imagePullSecrets: #使用的secret
- name: registry-secret
pod的服务能通过nodeport正常访问,但是prometheus监控中提示Get "https://172.20.107.216:9163/metrics": context deadline exceeded
错误,求大佬指教。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论