-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/loadbalancingexporter] add docs/example for k8s service re…
…solver (#24362) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> improve document for k8s service resolver of exporter/loadbalancingexporter **Link to tracking Issue:** <Issue number if applicable> #24287 **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.> Add example/k8s-resolver/README.md The description of the k8s resolver from exporter/loadbalancingexporter/README.md can be jump-linked to example. Signed-off-by: Yuan Fang <yuanfang@alauda.io>
- Loading branch information
Showing
3 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
# If your change doesn't affect end users, such as a test fix or a tooling change, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'enhancement' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: loadbalancingexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Added docs for k8s service resolver. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [24287] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
exporter/loadbalancingexporter/example/k8s-resolver/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Trace ID aware load-balancing exporter demo for kubernetes service resolver | ||
|
||
## How to run | ||
|
||
1. Pre-requirements: | ||
```shell | ||
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml | ||
``` | ||
|
||
2. Once the opentelemetry-operator is deployed, create the OpenTelemetry Collector (otelcol) instances, ServiceAccount and other necessary resources, run: | ||
```shell | ||
kubectl apply -f - <<EOF | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: observability | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: loadbalancer-role | ||
namespace: observability | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- endpoints | ||
verbs: | ||
- list | ||
- watch | ||
- get | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: loadbalancer | ||
namespace: observability | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: loadbalancer-rolebinding | ||
namespace: observability | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: loadbalancer-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: loadbalancer | ||
namespace: observability | ||
--- | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: loadbalancer | ||
namespace: observability | ||
spec: | ||
image: docker.io/jpkroehling/otelcol-with-k8sresolver:latest | ||
serviceAccount: loadbalancer | ||
config: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
processors: | ||
exporters: | ||
loadbalancing: | ||
protocol: | ||
otlp: | ||
tls: | ||
insecure: true | ||
resolver: | ||
k8s: | ||
service: backends-collector-headless.observability | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: | ||
- otlp | ||
processors: [] | ||
exporters: | ||
- loadbalancing | ||
--- | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: backends | ||
namespace: observability | ||
spec: | ||
replicas: 5 | ||
config: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
processors: | ||
exporters: | ||
logging: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: | ||
- otlp | ||
processors: [] | ||
exporters: | ||
- logging | ||
EOF | ||
``` | ||
|
||
## How does it work | ||
- The `loadbalancer` and `backends` OpenTelemetryCollector are recognised by the opentelemetry-operator, which then creates the appropriate deployment resources. | ||
- The `loadbalancer` ServiceAccount is used to assign to the pods corresponding to the deployment loadbalancer and backends. | ||
- The `loadbalancer-role` Role grants `get`, `list`, and `watch` permissions on endpoint resources in its namespace. Having these permissions is essential for a kubernetes service resolver to work properly. | ||
- The `loadbalancer-rolebinding` RoleBinding is used to bind Role `loadbalancer-role` to ServiceAccount `loadbalancer`. |