更新时间:2025-12-24 GMT+08:00
分享

开启Pod监控指标

CCI2.0支持Pod资源基础监控能力,提供CPU、内存、磁盘、网络等多种监控指标,满足用户对Pod资源的基本监控需求。Pod内置系统agent,默认会以http服务的形式提供Pod和容器的监控指标。Agent集成到Pod里面,会占用Pod内资源,建议您预留30MB的内存。

资源基础监控包含CPU/内存/磁盘等类别,具体请参见资源监控指标

配置示例

apiVersion: cci/v2
kind: Pod
metadata:
  annotations:
    resource.cci.io/pod-size-specs: 2.00_4.0
    resource.cci.io/instance-type: general-computing #实例类型
    monitoring.cci.io/enable-pod-metrics: 'true'
    monitoring.cci.io/metrics-port: '19100'
  labels:
    app: nginx
  name: 'test2'
  namespace: test
spec:
  containers:
  - name: centos
    image: centos:latest
    resources:
      limits:
        cpu: 2000m
        memory: 4096Mi
      requests:
        cpu: 2000m
        memory: 4096Mi
    command:
    - sh
    - '-c'
    - 'while true; do echo hello; sleep 10; done'	
    lifecycle: {}
  dnsPolicy: ''
  imagePullSecrets:
    - name: imagepull-secret
表1 参数说明

Annotation

是否必填

参数类型

描述

monitoring.cci.io/enable-pod-metrics

string

是否开启监控指标特性,默认为true,关闭为false。

monitoring.cci.io/metrics-port

string

指定pod exporter启动的监听端口,端口范围(1~65535),默认19100。

获取资源监控指标

开启Pod监控指标后,在能访问Pod的网络内,通过执行如下命令获取Pod的监控数据。

curl $podIP:$port/metrics
  • $podIP:Pod的IP地址。
  • $port:监听端口。

相关文档