Skip to content

Instantly share code, notes, and snippets.

@kevincantu
Last active July 22, 2022 12:31
Show Gist options
  • Save kevincantu/5f032fe5e00e0aa67397f8ff84c7e550 to your computer and use it in GitHub Desktop.
Save kevincantu/5f032fe5e00e0aa67397f8ff84c7e550 to your computer and use it in GitHub Desktop.
OpenTelemetry Collector's OTLP gRPC receiver config on Envoy / Contour
---
apiVersion: v1
kind: ConfigMap
metadata:
name: otel-collector-conf
namespace: monitoring
labels:
app: opentelemetry
component: otel-collector-conf
data:
otel-collector-config: |
receivers:
otlp:
protocols:
grpc:
tls_settings:
cert_file: /tls/cert.pem
key_file: /tls/key.pem
http:
processors:
batch:
memory_limiter:
# Same as --mem-ballast-size-mib CLI argument
ballast_size_mib: 1024
# 80% of maximum memory
limit_mib: 1600
# 25% of limit
spike_limit_mib: 512
check_interval: 5s
extensions:
health_check: {}
zpages:
endpoint: "0.0.0.0:55679" # default was localhost only!
exporters:
logging:
logLevel: debug
honeycomb:
api_key: "$HONEYCOMB_API_KEY"
dataset: "apps"
api_url: "https://api.honeycomb.io"
service:
extensions: [health_check, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [logging, honeycomb]
---
apiVersion: v1
kind: Service
metadata:
name: otel-collector
namespace: monitoring
labels:
app: opentelemetry
component: otel-collector
spec:
ports:
- name: zpages
port: 55679
# when proxied: http://localhost:8001/api/v1/namespaces/monitoring/services/http:otel-collector:55679/proxy/debug/tracez
- name: otlp-grpc # Default endpoint for OpenTelemetry receiver.
port: 55680
- name: otlp-http
port: 55681
- name: jaeger-grpc # Default endpoing for Jaeger gRPC receiver
port: 14250
- name: jaeger-thrift-http # Default endpoint for Jaeger HTTP receiver.
port: 14268
- name: zipkin # Default endpoint for Zipkin receiver.
port: 9411
- name: metrics # Default endpoint for querying metrics.
port: 8888
selector:
component: otel-collector
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: otel-collector
namespace: monitoring
labels:
app: opentelemetry
component: otel-collector
spec:
selector:
matchLabels:
app: opentelemetry
component: otel-collector
minReadySeconds: 5
progressDeadlineSeconds: 120
replicas: 2
template:
metadata:
labels:
app: opentelemetry
component: otel-collector
spec:
containers:
- command:
- "/otelcontribcol"
- "--log-level=DEBUG"
- "--config=/conf/otel-collector-config.yaml"
# Memory Ballast size should be max 1/3 to 1/2 of memory.
- "--mem-ballast-size-mib=1024"
#image: otel/opentelemetry-collector-dev:latest
image: otel/opentelemetry-collector-contrib:0.11.0
name: otel-collector
envFrom:
- secretRef:
name: otel-collector
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 200m
memory: 400Mi
ports:
- containerPort: 55679 # Default endpoint for ZPages.
- containerPort: 55680 # OTLP gRPC receiver.
- containerPort: 55681 # OTLP HTML/JSON receiver.
- containerPort: 14250 # Default endpoint for Jaeger HTTP receiver.
- containerPort: 14268 # Default endpoint for Jaeger HTTP receiver.
- containerPort: 9411 # Default endpoint for Zipkin receiver.
- containerPort: 8888 # Default endpoint for querying metrics.
volumeMounts:
- name: otel-collector-config-vol
mountPath: /conf
- name: otel-tls
mountPath: /tls
livenessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
readinessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
volumes:
- name: otel-collector-config-vol
configMap:
name: otel-collector-conf
items:
- key: otel-collector-config
path: otel-collector-config.yaml
- name: otel-tls
secret:
secretName: otel-wildcard
items:
- key: tls.crt
path: cert.pem
- key: tls.key
path: key.pem
# Routing for OTLP (gRPC) traffic wrapped in HTTP/2 TLS
#
# As of 2020-10-06:
# - the yages echo app works when terminating TLS at Envoy (h2c), but
# - otel does not and needs a TLS passthrough (h2).
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: otel-collector
namespace: monitoring
annotations:
kubernetes.io/ingress.class: "contour"
labels:
app: opentelemetry
component: otel-collector
spec:
virtualhost:
fqdn: otel.staging.test
tls:
#secretName: otel-wildcard
passthrough: true
tcpproxy:
services:
- name: otel-collector
port: 55680
# tls: HTTP/1 TLS
# h2: HTTP/2 TLS
# h2c: HTTP/2 cleartext
protocol: h2
@kevincantu
Copy link
Author

@kevincantu
Copy link
Author

Incidentally the config file alone works locally too inside of this:

docker run --rm --interactive --tty --volume `pwd`:/conf otel/opentelemetry-collector-contrib:0.11.0 /otelcontribcol --config /conf/otel-config.yaml --log-level=DEBUG --publish 55680:55680 --publish 55679:55679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment