Skip to content

Commit

Permalink
[extension/k8s leader elector] Stability level alpha and enable chang…
Browse files Browse the repository at this point in the history
…elog (#38426)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
- Change the stability level to alpha and allow print it in the change
log.
- Also adjust the documentation

PR for
[Implementation](#38015)
Pr for [Basic
structure](#37266)

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

#34460
<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation
provided
<!--Please delete paragraphs that you did not use before submitting.-->
  • Loading branch information
rakesh-garimella authored Mar 7, 2025
1 parent 51466a2 commit 0ef14bb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .chloggen/update-doc-k8s-leader-elector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type:
new_component
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component:
k8sleaderelector
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: allows single instance of the receiver/exporter to be active via kubernetes leader election mechanism

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34460]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 1 addition & 0 deletions cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/textencodingextension v0.121.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/zipkinencodingextension v0.121.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension v0.121.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/k8sleaderelector v0.121.0

exporters:
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.121.0
Expand Down
12 changes: 9 additions & 3 deletions extension/k8sleaderelector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development] |
| Stability | [alpha] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fk8sleaderelector%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fk8sleaderelector) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fk8sleaderelector%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fk8sleaderelector) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dmitryax](https://www.github.com/dmitryax), [@rakesh-garimella](https://www.github.com/rakesh-garimella) |

[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development
[alpha]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#alpha
<!-- end autogenerated section -->

This extension enables OpenTelemetry components to run in HA mode across a Kubernetes cluster. The component that owns the lease becomes the leader and becomes the active instance.
Expand All @@ -16,12 +16,13 @@ This extension enables OpenTelemetry components to run in HA mode across a Kuber
## How It Works

The extension uses k8s.io/client-go/tools/leaderelection to perform leader election. The component that owns the lease becomes the leader and runs the function defined in onStartedLeading. If the leader loses the lease, it runs the function defined in onStoppedLeading, stops its operation, and waits to acquire the lease again.

## Configuration

```yaml
receivers:
my_awesome_receiver:
leader_elector: k8s_leader_elector
k8s_leader_elector: k8s_leader_elector
extensions:
k8s_leader_elector:
auth_type: kubeConfig
Expand All @@ -44,6 +45,11 @@ service:
| **renew_deadline** | The deadline for renewing the lease. It must be less than the lease duration. | 10s |
| **retry_period** | The period for retrying the leader election. | 2s |
### Delete the lease object
```shell
kubectl delete leases.coordination.k8s.io -n <namespace> <lease_name>
```

### Suggested RBAC
```yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extension/k8sleaderelector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: k8s_leader_elector
status:
class: extension
stability:
development: [extension]
alpha: [extension]
distributions: []
codeowners:
active: [dmitryax, rakesh-garimella]
Expand Down

0 comments on commit 0ef14bb

Please sign in to comment.