OpenTelemetry Operator
Deploy OpenTelemetry Operator for automatic instrumentation and observability in Kubernetes clusters
Deploy OpenTelemetry Operator, Collector, and Cluster Monitoring in your Kubernetes environment using our automated setup script. This integration provides automatic instrumentation for applications and comprehensive observability for your cluster.
Prerequisites
Before setting up the OpenTelemetry Operator, ensure you have:
- ✅ Kubernetes Cluster: A running Kubernetes cluster (v1.19+)
- ✅ kubectl: Configured and connected to your cluster
- ✅ helm: Installed (v3.9 or higher)
- ✅ git: Installed for downloading setup scripts
- ✅ Cluster Admin Access: Required for creating cluster-wide resources
- ✅ Last9 Account: With integration credentials for traces, logs, and metrics
-
Download the Setup Script
First, download the automated setup script from the Last9 GitHub repository:
# Download shell script directly from GitHubcurl -O https://raw.githubusercontent.com/last9/opentelemetry-examples/main/otel-collector/otel-operator/last9-otel-setup.shchmod +x last9-otel-setup.sh -
Choose Your Installation Option
The setup script provides multiple installation options based on your observability needs:
Install Everything: OpenTelemetry Operator + Collector + Cluster Monitoring
./last9-otel-setup.sh \endpoint="{{ .Logs.WriteURL }}" \token="{{ .Logs.AuthValue }}" \monitoring-endpoint="{{ .Metrics.WriteURL }}" \username="{{ .Metrics.Username }}" \password="{{ .Metrics.WriteToken }}"This option provides:
- 🔍 Traces: Automatic application instrumentation via OpenTelemetry Operator
- 📊 Metrics: Complete cluster and application metrics monitoring
- 📝 Logs: Log collection and forwarding capabilities
Install OpenTelemetry Operator and Collector (for traces and manual instrumentation):
./last9-otel-setup.sh operator-only \endpoint="{{ .Logs.WriteURL }}" \token="{{ .Logs.AuthValue }}"Use this option when you want:
- Application tracing with automatic instrumentation
- Custom collector configurations
- No cluster-wide metrics monitoring
Install Only Collector for Logs (no operator, no automatic instrumentation):
./last9-otel-setup.sh logs-only \endpoint="{{ .Logs.WriteURL }}" \token="{{ .Logs.AuthValue }}"Use this option for:
- Log collection and forwarding
- Custom log processing
- No automatic application instrumentation
Install Only Cluster Monitoring (Prometheus stack for metrics):
./last9-otel-setup.sh monitoring-only \monitoring-endpoint="{{ .Metrics.WriteURL }}" \username="{{ .Metrics.Username }}" \password="{{ .Metrics.WriteToken }}"Use this option for:
- Kubernetes cluster metrics only
- No application tracing
- No log collection
Replace the placeholder values with your actual Last9 credentials from the Last9 Integrations page.
-
Verify Installation
Check that all components are deployed and running correctly:
# Check all pods in last9 namespace should be up and runningkubectl get pods -n last9Depending on your installation option, you should see pods like:
NAME READY STATUS RESTARTS AGEopentelemetry-operator-controller-manager-xxx-xxx 2/2 Running 0 2mlast9-otel-collector-xxx-xxx 1/1 Running 0 2mprometheus-last9-k8s-monitoring-prometheus-0 2/2 Running 0 2m (if monitoring included) -
Enable Application Auto-Instrumentation
To enable automatic OpenTelemetry instrumentation for your applications, add the appropriate annotation to your deployment:
apiVersion: apps/v1kind: Deploymentmetadata:name: my-java-appspec:template:metadata:annotations:instrumentation.opentelemetry.io/inject-java: "last9/l9-instrumentation"spec:containers:- name: my-appimage: my-java-app:latestapiVersion: apps/v1kind: Deploymentmetadata:name: my-nodejs-appspec:template:metadata:annotations:instrumentation.opentelemetry.io/inject-nodejs: "last9/l9-instrumentation"spec:containers:- name: my-appimage: my-nodejs-app:latestapiVersion: apps/v1kind: Deploymentmetadata:name: my-python-appspec:template:metadata:annotations:instrumentation.opentelemetry.io/inject-python: "last9/l9-instrumentation"spec:containers:- name: my-appimage: my-python-app:latestapiVersion: apps/v1kind: Deploymentmetadata:name: my-dotnet-appspec:template:metadata:annotations:instrumentation.opentelemetry.io/inject-dotnet: "last9/l9-instrumentation"spec:containers:- name: my-appimage: my-dotnet-app:latestAfter adding the annotation, restart your deployment:
kubectl rollout restart deployment/my-app -n <your-namespace>
Advanced Configuration
Custom Environment Settings
Override the deployment.environment attribute to match your environment:
./last9-otel-setup.sh \ endpoint="{{ .Logs.WriteURL }}" \ token="{{ .Logs.AuthValue }}" \ monitoring-endpoint="{{ .Metrics.WriteURL }}" \ username="{{ .Metrics.Username }}" \ password="{{ .Metrics.WriteToken }}" \ env=productionRunning on Nodes with Taints
If your Kubernetes nodes have taints (e.g., dedicated monitoring nodes), you need to provide tolerations:
-
Create Tolerations Configuration
Create a file named
tolerations.yaml:# tolerations.yamltolerations:- key: "monitoring"operator: "Equal"value: "true"effect: "NoSchedule"nodeSelector:monitoring: "true"nodeExporterTolerations:- operator: "Exists" -
Run Installation with Tolerations
./last9-otel-setup.sh \endpoint="{{ .Logs.WriteURL }}" \token="{{ .Logs.AuthValue }}" \monitoring-endpoint="{{ .Metrics.WriteURL }}" \username="{{ .Metrics.Username }}" \password="{{ .Metrics.WriteToken }}" \tolerations-file=tolerations.yaml
Understanding the Components
OpenTelemetry Operator
The operator provides:
- Automatic Instrumentation: Injects OpenTelemetry libraries into applications
- Collector Management: Manages OpenTelemetry Collector deployments
- Custom Resources: Provides CRDs for OpenTelemetry configuration
- Language Support: Supports Java, Node.js, Python, .NET, and Go applications
OpenTelemetry Collector
The collector handles:
- Data Reception: Receives traces, metrics, and logs from applications
- Data Processing: Filters, transforms, and enriches telemetry data
- Data Export: Forwards processed data to Last9 endpoints
- Service Discovery: Automatically discovers services in Kubernetes
Cluster Monitoring (Optional)
When enabled, provides:
- Kubernetes Metrics: Cluster state, resource usage, and performance metrics
- Node Metrics: Hardware and OS metrics from cluster nodes
- Application Metrics: Custom application metrics and performance indicators
Verification
-
Check Operator Status
Verify the OpenTelemetry Operator is running:
kubectl get pods -n opentelemetry-operator-systemkubectl logs -n opentelemetry-operator-system deployment/opentelemetry-operator-controller-manager -
Verify Instrumentation Configuration
Check the instrumentation resource:
kubectl get instrumentation -n last9kubectl describe instrumentation l9-instrumentation -n last9 -
Test Application Instrumentation
Deploy a test application and verify traces are being generated:
kubectl logs <your-app-pod> | grep -i opentelemetry -
Verify Data in Last9
Log into your Last9 account and check that data is being received:
- Traces: Check the Traces dashboard
- Metrics: Check Grafana
- Logs: Check the Logs dashboard
Uninstallation
To remove all OpenTelemetry and monitoring components:
./last9-otel-setup.sh uninstall-allThis command will:
- Remove all OpenTelemetry components
- Delete cluster monitoring stack
- Clean up secrets and configurations
- Remove the
last9namespace
Troubleshooting
Operator Not Starting
Check operator logs and resource requirements:
kubectl logs -n opentelemetry-operator-system deployment/opentelemetry-operator-controller-managerkubectl describe pod -n opentelemetry-operator-system <operator-pod-name>Application Not Instrumented
Verify annotation syntax and instrumentation resource:
kubectl describe pod <your-app-pod>kubectl get instrumentation -n last9 -o yamlCommon issues:
- Incorrect annotation name or value
- Missing instrumentation resource
- Unsupported application runtime
Collector Issues
Check collector configuration and logs:
kubectl logs -n last9 <collector-pod-name>kubectl describe configmap -n last9 <collector-config>Data Not Appearing in Last9
Verify credentials and network connectivity:
kubectl get secrets -n last9kubectl logs -n last9 <collector-pod-name> | grep -i errorBest Practices
- Resource Limits: Set appropriate resource limits for operator and collector components
- Environment Labeling: Use consistent environment labels across all services
- Instrumentation Testing: Test auto-instrumentation in development before production
- Monitoring Stack Health: Monitor the health of OpenTelemetry components themselves
- Regular Updates: Keep the operator and collectors updated to latest versions
Additional Resources
Need Help?
If you encounter any issues or have questions:
- Join our Discord community for real-time support
- Contact our support team at support@last9.io