OpenTelemetry Collector (k8s) 镜像为 Kubernetes 环境定制,是 OpenTelemetry 可观测性数据处理管道的核心组件。该镜像整合了 https://github.com/open-telemetry/opentelemetry-collector 仓库的核心组件及contrib 扩展组件,专为在 Kubernetes 集群中运行设计,提供可观测性数据(traces、metrics、logs)的统一收集、处理、转换与导出能力。
1. Docker 运行(单机测试)
bashdocker 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)。
2. Docker Compose 配置(本地测试)
yamlversion: '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
3. Kubernetes 部署(生产环境)
推荐通过 Deployment 或 DaemonSet 部署(根据数据收集范围选择),以下为 Deployment 示例:
1. 创建配置文件 ConfigMap
otel-collector-config.yaml:
yamlapiVersion: 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: "http://prometheus-server.observability:80/api/v1/write" 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:
yamlapiVersion: 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 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务