本站支持搜索的镜像仓库:Docker Hub、gcr.io、ghcr.io、quay.io、k8s.gcr.io、registry.gcr.io、elastic.co、mcr.microsoft.com
OpenTelemetry Collector (k8s) 镜像为 Kubernetes 环境定制,是 OpenTelemetry 可观测性数据处理管道的核心组件。该镜像整合了 open-telemetry/opentelemetry-collector 仓库的核心组件及contrib 扩展组件,专为在 Kubernetes 集群中运行设计,提供可观测性数据(traces、metrics、logs)的统一收集、处理、转换与导出能力。
docker run -d \ --name otel-collector-k8s \ -p 4317:4317 # OTLP gRPC 接收器端口 \ -p 4318:4318 # OTLP HTTP 接收器端口 \ -p 8888:8888 # 指标暴露端口(用于自身监控) \ -v /path/to/otel-collector-config.yaml:/etc/otelcol/config.yaml \ otel/opentelemetry-collector-k8s:latest
注:
otel/opentelemetry-collector-k8s为官方镜像名称,实际使用时需替换为具体版本标签(如0.91.0)。
version: '3' services: otel-collector: image: otel/opentelemetry-collector-k8s:latest container_name: otel-collector-k8s ports: - "4317:4317" # OTLP gRPC - "4318:4318" # OTLP HTTP - "8888:8888" # 自身指标暴露 volumes: - ./otel-collector-config.yaml:/etc/otelcol/config.yaml environment: - OTEL_LOG_LEVEL=info # 日志级别:debug/info/warn/error restart: unless-stopped
推荐通过 Deployment 或 DaemonSet 部署(根据数据收集范围选择),以下为 Deployment 示例:
1. 创建配置文件 ConfigMap
otel-collector-config.yaml:
apiVersion: v1 kind: ConfigMap metadata: name: otel-collector-config namespace: observability data: config.yaml: | receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 prometheus: config: scrape_configs: - job_name: 'otel-collector' static_configs: - targets: ['localhost:8888'] processors: batch: # 批量处理以减少导出请求数 resourcedetection: # 自动添加 Kubernetes 资源元数据 detectors: [k8s] timeout: 10s override: false exporters: logging: # 控制台输出(调试用) loglevel: info prometheusremotewrite: # 导出至 Prometheus endpoint: "[***]" service: pipelines: traces: receivers: [otlp] processors: [batch, resourcedetection] exporters: [logging] metrics: receivers: [otlp, prometheus] processors: [batch, resourcedetection] exporters: [logging, prometheusremotewrite]
2. 创建 Deployment
otel-collector-deployment.yaml:
apiVersion: apps/v1 kind: Deployment metadata: name: otel-collector namespace: observability spec: replicas: 1 selector: matchLabels: app: otel-collector template: metadata: labels: app: otel-collector spec: containers: - name: otel-collector image: otel/opentelemetry-collector-k8s:latest resources: limits: cpu: 1000m memory: 1Gi requests: cpu: 200m memory: 256Mi ports: - containerPort: 4317 # OTLP gRPC - containerPort: 4318 # OTLP HTTP - containerPort: 8888 # 自身指标 volumeMounts: - name: config-volume mountPath: /etc/otelcol/config.yaml subPath: config.yaml env: - name: OTEL_LOG_LEVEL value: "info" - name: K8S_NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName volumes: - name: config-volume configMap: name: otel-collector-config
Collector 通过配置文件(默认路径 /etc/otelcol/config.yaml)定义数据处理流程,核心配置项包括:
| 配置项 | 说明 |
|---|---|
receivers | 定义数据来源(如 OTLP、Prometheus、Jaeger、Filelog 等),每个接收器含特定配置(端口、协议、采集规则)。 |
processors | 定义数据处理逻辑(如 batch 批量处理、filter 数据过滤、resourcedetection 元数据添加、sampling 采样等)。 |
exporters | 定义数据导出目标(如 logging 控制台、otlp 远程 OTLP 服务、prometheusremotewrite Prometheus 写入接口、jaeger Jaeger 后端等)。 |
service | 定义数据管道(pipelines),将接收器、处理器、导出器关联,按数据类型(traces/metrics/logs)划分。 |
Collector 支持通过环境变量调整运行时行为,常用变量:
| 变量名 | 说明 | 默认值 |
|---|---|---|
OTEL_CONFIG_FILE | 配置文件路径 | /etc/otelcol/config.yaml |
OTEL_LOG_LEVEL | 日志级别(debug/info/warn/error) | info |
OTEL_RESOURCE_ATTRIBUTES | 全局资源属性(键值对,如 service.name=my-service,cluster=prod) | 空 |
K8S_NODE_NAME | Kubernetes 节点名称(用于 resourcedetection 处理器,通常通过 downward API 注入) | 自动从节点元数据获取 |
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录方式配置轩辕镜像加速服务,包含7个详细步骤
在 Linux 系统上配置轩辕镜像源,支持主流发行版
在 Docker Desktop 中配置轩辕镜像加速,适用于桌面系统
在 Docker Compose 中使用轩辕镜像加速,支持容器编排
在 k8s 中配置 containerd 使用轩辕镜像加速
在宝塔面板中配置轩辕镜像加速,提升服务器管理效率
在 Synology 群晖NAS系统中配置轩辕镜像加速
在飞牛fnOS系统中配置轩辕镜像加速
在极空间NAS中配置轩辕镜像加速
在爱快ikuai系统中配置轩辕镜像加速
在绿联NAS系统中配置轩辕镜像加速
在威联通NAS系统中配置轩辕镜像加速
在 Podman 中配置轩辕镜像加速,支持多系统
配置轩辕镜像加速9大主流镜像仓库,包含详细配置步骤
无需登录即可使用轩辕镜像加速服务,更加便捷高效
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429