Skip to content

feat(stackable-operator): Add headless/metrics service name functions to RoleGroupRef #1069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 10, 2025
Merged
3 changes: 3 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ All notable changes to this project will be documented in this file.
fieldPath: spec.nodeName
```

- Add associated functions on `RoleGroupRef` to return the rolegroup headless and metrics service name ([#1069]).

### Changed

- Update `kube` to `1.1.0` ([#1049]).
Expand All @@ -51,6 +53,7 @@ All notable changes to this project will be documented in this file.
[#1060]: https://github.com/stackabletech/operator-rs/pull/1060
[#1064]: https://github.com/stackabletech/operator-rs/pull/1064
[#1068]: https://github.com/stackabletech/operator-rs/pull/1068
[#1069]: https://github.com/stackabletech/operator-rs/pull/1069
[#1071]: https://github.com/stackabletech/operator-rs/pull/1071

## [0.93.2] - 2025-05-26
Expand Down
21 changes: 21 additions & 0 deletions crates/stackable-operator/src/role_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,27 @@ impl<K: Resource> RoleGroupRef<K> {
pub fn object_name(&self) -> String {
format!("{}-{}-{}", self.cluster.name, self.role, self.role_group)
}

/// Returns the service name used by rolegroups for cluster internal communication only.
///
/// The internal use of of this service name is indicated by the `-headless` suffix.
/// This service should not be used for communication to external services or clients
/// and also should not be used to export metrics (like Prometheus). Metrics should be
/// instead exposed via a dedicated service. Use [`Self::rolegroup_metrics_service_name`]
/// instead.
pub fn rolegroup_headless_service_name(&self) -> String {
format!("{name}-headless", name = self.object_name())
}

/// Returns the service name used by rolegroups to expose metrics (like Prometheus).
///
/// The use for metrics only is indicated by the `-metrics` suffix. This service
/// should not be used for any internal communication or any other external
/// communication. For internal communication, use [`Self::rolegroup_headless_service_name`]
/// instead.
pub fn rolegroup_metrics_service_name(&self) -> String {
format!("{name}-metrics", name = self.object_name())
}
}

impl<K: Resource> Display for RoleGroupRef<K> {
Expand Down