Getty Images

Deploy OpenTelemetry to improve Kubernetes observability

Deploying OpenTelemetry on Kubernetes can give teams a leg up in observability monitoring. It only takes a few simple steps to get the tool up and running.

Kubernetes observability can be complex, but observability framework OpenTelemetry can enable application monitoring and observability across entire clusters.

Part of what makes Kubernetes valuable is that a single cluster can serve as a hosting environment for many distinct apps. However, a core challenge when deploying multiple apps on Kubernetes is that each app can expose monitoring data in a distinct way, making it difficult to monitor all apps in a uniform fashion.

OpenTelemetry is one way to solve this challenge. Using just one collection tool, OpenTelemetry can efficiently collect monitoring data for any application within a Kubernetes cluster, provided it uses the OpenTelemetry framework. Teams can easily deploy OpenTelemetry for improved Kubernetes observability with either a Helm chart or an operator.

What is OpenTelemetry?

OpenTelemetry is a monitoring and observability framework designed to provide a consistent and standardized way to generate and collect monitoring data from any application.

Using OpenTelemetry's libraries and toolkits, developers can embed observability functionality into applications as they build them. In other words, they can program apps to expose monitoring data according to the specifications OpenTelemetry defines. Then, any monitoring and data analytics tool that supports the OpenTelemetry specifications can collect that data.

Why is OpenTelemetry useful?

The main purpose of OpenTelemetry is to simplify monitoring and data collection by eliminating the need for teams to monitor each application in a unique way. Any app that adheres to the OpenTelemetry specifications is compatible with any data collection and monitoring tool that supports OpenTelemetry.

Consequently, to use a specific monitoring tool for an application, it's not necessary to design the app so that it exposes monitoring data in whichever way the tool expects. As long as the app and the tool both support OpenTelemetry, they'll be compatible. This also lets IT teams easily switch between OpenTelemetry-compatible monitoring tools without having to overhaul apps' monitoring and observability frameworks.

In addition, application developers don't need to make any special effort to enable OpenTelemetry support. Instead, they can simply use OpenTelemetry's ready-made libraries.

OpenTelemetry's major caveat is that monitoring and observability tool vendors must choose to support OpenTelemetry for developers to use it in conjunction with their apps. Although there is no universal mandate requiring vendors to do this, OpenTelemetry does have widespread endorsement as a community-backed endeavor that has been around for several years. According to the project's documentation, more than 40 monitoring and observability vendors currently support the framework.

The benefits of OpenTelemetry for Kubernetes

OpenTelemetry can streamline monitoring and observability for applications hosted in any environment, but the framework is especially valuable for monitoring and observing Kubernetes-hosted applications.

A Kubernetes cluster can be home to many distinct apps. The ability to provide an environment for hosting any and all apps that an organization needs to run is part of what makes Kubernetes appealing.

However, Kubernetes itself offers no built-in application monitoring or observability tooling. If each app in a cluster exposes monitoring data in a different way, the complexity can be overwhelming, potentially requiring multiple monitoring and observability tools to support the various approaches. This is inefficient at best and, at worst, leads to critical observability blind spots due to an inability to collect and analyze all relevant data.

OpenTelemetry alleviates this problem. By deploying OpenTelemetry inside a Kubernetes cluster, teams can monitor and observe all their applications using a consistent framework, provided that the apps support OpenTelemetry. Adding OpenTelemetry support to most applications is easy, thanks to preexisting libraries that developers can use without having to redesign apps or rewrite substantial amounts of source code.

How to install OpenTelemetry in a Kubernetes cluster

There are two main ways to install OpenTelemetry in Kubernetes: a Helm chart or an operator. Both approaches are simple. Let's walk through each one.

Prerequisite: Install cert-manager

Before installing OpenTelemetry using either the Helm chart or the operator approach, you need to set up cert-manager, which provides X.509 certificates as resource types in Kubernetes. In most cases, you can set up cert-manager with the following command:

kubectl apply -f 
https://github.com/cert-manager/cert-manager/releases/download/v1.13.1/cert-manager.yaml

For more complex installation scenarios, refer to the cert-manager installation documentation.

1. Install OpenTelemetry using a Helm chart

To install the OpenTelemetry Helm chart, first add the official OpenTelemetry Helm repository:

helm repo add open-telemetry https://open- telemetry.github.io/opentelemetry-helm-charts
helm repo update

Then, install the chart with the following command:

helm install opentelemetry-operator open-telemetry/opentelemetry-operator

2. Install OpenTelemetry using an operator

To install the OpenTelemetry operator, run the following command:

kubectl apply -f 
https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml

Then, create an OpenTelemetry deployment manifest, as demonstrated in the following example configuration from OpenTelemetry:

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: simplest
spec:
  config: |
	receivers:
  	otlp:
    	protocols:
      	grpc:
      	http:
	processors:

	exporters:
  	# NOTE: Prior to v0.86.0 use `logging` instead of `debug`.
  	debug:

	service:
  	pipelines:
    	traces:
      	receivers: [otlp]
      	processors: []
      	exporters: [debug]

For details on all configuration options available, check out the OpenTelemetry operator documentation.

Finally, apply your deployment with the following command:

kubectl apply -f /path/to/manifest.yaml

Once you've installed OpenTelemetry in your clusters,  you can begin collecting observability insights from your applications using any OpenTelemetry-compatible tool.

Chris Tozzi, senior editor of content and a DevOps analyst at Fixate IO, has worked as a journalist and Linux systems administrator with particular interest in open source Agile infrastructure and networking.

Dig Deeper on IT systems management and monitoring