Exposing a Collector for cross cluster communication
Exposing an OpenTelemetry Collector currently requires a
number of configuration steps. The goal of this blog post is to demonstrate
how to establish a secure communication
between two collectors in different
Kubernetes clusters.
Details of CRDs and dependency installations are not covered by this post.
Overview¶
When it comes to making collectors publicly accessible, the first thing that comes to mind is the secure transmission of user data via TLS. However, authentication to the server is at least as important to prevent unauthorized services from sending data.
The OpenTelemetry Collector supports different authentication methods. The most used are probably:
- TLS Authentication
- OpenID Connect (OIDC-Authentication)
- HTTP Basic Authentication
This article focuses on HTTP Basic Authentication for simplicity. It is intended to show how a secure setup can be operated without key management or further third party services.
For more information about TLS configuration I would like to refer to the article How TLS provides identification, authentication, confidentiality, and integrity and the Collector TLS-Config description on Github.
If you are interested in using an external authentication provider, I advise you to have a look at the article Securing your OpenTelemetry Collector by Juraci Paixão Kröhling on this topic. He explains how OpenTelemetry collectors can be secured using the OIDC-Authenticator extension, and how Keycloak can be configured as an authentication provider.
Basic Authentication¶
The HTTP Basic Authentication mechanism is quite simple. An HTTP user agent
(e.g., a web browser) provides a username and password combination on every
request. Transmitted credentials are included in the HTTP header by the key
Authorization
when the connection is established. As a value the
authentication method basic
is mentioned first, followed by the encoded
credentials. Note that the credential form is username:password
.
In the following example, dXNlci0xOjEyMzQK
is the encoding for a combination
of username=user-1
and password=1234
. Note to encode or decode base64
values, you can use
You can easily create your own user password combination using the base64 cli tool.
Data flow¶
The following graph illustrates the target topology. The goal is to transfer traces generated by a test application via a dedicated collector to a publicly accessible cluster. The receiving collector uses the transmitted 'Basic' HTTP Authentication credentials to check whether the sender is authorized to store data. Finally, transmitted traces are stored in a Jaeger in-memory
Prerequisites¶
Interfaces and behavior may change in the future. Therefore, the versions used in this setup are mentioned in brackets.
- A Kubernetes[v1.23.3] cluster with a public address with ingress-nginx-controller[v1.2.1] installed.
- A Kubernetes[v1.23.3] edge cluster to create a test cluster. Using Kind is recommended.
- Installed OpenTelemetry Operator[v0.58.0] on both ends.
- Installed Jaeger Operator[v1.37.0] on your public cluster.
- Installed cert-manager[v1.9.1] on your public cluster.
Remote cluster configuration¶
Since all components except the Jaeger backend depend on a following component, we begin by deploying the backend.
In the next step we create an OpenTelemetry Collector using the
OpenTelemetryCollector
CRD. The most important entries are mode
, image
and
the configured basicauth extension. In the manifest below the mode deployment
was chosen to guarantee that at least one collector pod is available for
processing incoming information. Furthermore the default collector image was
overwritten with the
contrib version.
This is necessary because the
core version does
not contain the
basicauth
extension. This extension was configured with the name basicauth/server
and
registered in otlp/basicauth
. As
otlp exporter
endpoint the Jaeger in-memory service was configured.
After a successful installation, a pod for the Jaeger backend and the OpenTelemetry collector should be created in the selected namespace.
Also the following services should be available:
Finally, cert-manager is configured to automatically request TLS certificates
from Let’s Encrypt and make it available to the
Ingress TLS configuration. The following ClusterIssuer
and Ingress
entries
expose the otel-collector-app-collector
service. Note that you'll need to
replace values for the email
and host
fields.
Edge Cluster configuration¶
In order to be able to determine the origin of the transmitted traces, the span-tags are extended by identifying metadata with the help of the k8sattributes processor. It is available in the OpenTelemetry Collector contrib version. In the next step we create a service account with the necessary permissions. If you want to learn more about the K8s metadata, you can read this post "Improved troubleshooting using K8s metadata".
Let's have a quick look on the most important edge collector settings. A
daemonset
is used as deployment mode to ensure that one collector instance per
node exists. The basicauth
extension contains username
and password
to
identify itself to the exposed remote collector. More container and node
specific information are provided by the k8sattributes
processor via the
kubernetes
Kubernetes downward-api.
What is not covered is the cluster availability zone and the cluster name. To be
able to identify the reported spans later, they are inserted manually with the
help of the resource
processor. Last, the OTLP exporter endpoint has also been
given a placeholder value that must be replaced with your remote cluster domain.
After a successful installation, a daemonset
with the name
otel-collector-app-collector
should have been created. This ensures that each
cluster node has a local collector instance up and running.
Deploy trace generator to generate test data¶
Testing¶
Now spans generated in the edge cluster should be extended with origin metadata. These are then transferred to the remote cluster and stored in the Jaeger backend. Jaeger itself provides a UI for inspecting transmitted data.
An easy way to reach the UI is by port forwarding to your local system.
Conclusion¶
Configurations like Ingress
, ClusterIssuer
and OpenTelemetryCollector
on
client and server side have to be configured manually. Depending on installed
Kubernetes components, the configurations differ a lot. Overall the
configuration is very error-prone. In the future the exposing of the collector
should be simplified with the help of the OpenTelemetry operator. If you are
interested in the development, you can follow
Github issue #902
to stay updated.
References¶
- Securing your OpenTelemetry Collector
- Jaeger Tracing
- OpenTelemetry-Collector
- Distributions: contrib, core
- Extensions: basicauth, oidc
- Processors: resource, k8sattributes
- Exporters: otlp, logging
- Test-Application
- Basic HTTP Authentication
- Kubernetes Downward-API
- Let’s Encrypt
- Ingress NGINX gRPC example
- OpenTelemetry-Collector TLS-Config
- How TLS provides identification, authentication, confidentiality, and integrity