
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
本镜像为registry.k8s.io/prometheus-adapter/prometheus-adapter:v0.10.0的转存版本,是Kubernetes自定义指标API的实现组件。它能够将Prometheus收集的监控指标转换为Kubernetes API可识别的自定义指标,使Kubernetes HPA(Horizontal Pod Autoscaler)等功能可以基于Prometheus指标实现动态扩缩容。
Prometheus Adapter主要通过配置文件定义指标转换规则,常见配置项包括:
| 配置项 | 说明 | 示例 |
|---|---|---|
rules | 指标转换规则列表 | - seriesQuery: 'http_requests_total{namespace!="",pod!=""}' |
resources | 关联的Kubernetes资源 | resource: {resource: "pod", name: {matches: "pod"}} |
name | 生成的自定义指标名称 | name: {value: "http_requests"} |
metricsQuery | Prometheus查询语句 | metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>}[5m])) by (<<.GroupBy>>) |
Kubernetes部署清单(deployment.yaml)
yamlapiVersion: apps/v1 kind: Deployment metadata: name: prometheus-adapter namespace: monitoring spec: replicas: 1 selector: matchLabels: name: prometheus-adapter template: metadata: labels: name: prometheus-adapter spec: serviceAccountName: prometheus-adapter containers: - name: prometheus-adapter image: registry.k8s.io/prometheus-adapter/prometheus-adapter:v0.10.0 args: - --prometheus-url=http://prometheus-server.monitoring.svc:80 - --config=/etc/adapter/config.yaml - --metrics-relist-interval=1m volumeMounts: - name: config-volume mountPath: /etc/adapter volumes: - name: config-volume configMap: name: prometheus-adapter-config
配置文件(configmap.yaml)
yamlapiVersion: v1 kind: ConfigMap metadata: name: prometheus-adapter-config namespace: monitoring data: config.yaml: | rules: - seriesQuery: 'http_requests_total{namespace!="",pod!=""}' resources: overrides: namespace: {resource: "namespace"} pod: {resource: "pod"} name: matches: "^(.*)_total" as: "${1}_per_second" metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>}[5m])) by (<<.GroupBy>>)
RBAC配置(rbac.yaml)
yamlapiVersion: v1 kind: ServiceAccount metadata: name: prometheus-adapter namespace: monitoring --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus-adapter rules: - apiGroups: [""] resources: ["pods", "namespaces"] verbs: ["get", "list", "watch"] - apiGroups: ["custom.metrics.k8s.io"] resources: ["*"] verbs: ["get", "list", "watch", "create", "update"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: prometheus-adapter roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: prometheus-adapter subjects: - kind: ServiceAccount name: prometheus-adapter namespace: monitoring
部署完成后,可通过以下命令验证自定义指标是否正常暴露:
bashkubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务