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
WIP: Allow users to choose Endpoints/EndpoinSlice role in Prometheus and Prometheus Agent #6518
base: main
Are you sure you want to change the base?
Conversation
// +kubebuilder:default="Endpoints" | ||
// +kubebuilder:validation:Enum=Endpoints;EndpointSlice | ||
ServiceDiscoveryRole string `json:"serviceDiscoveryRole,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it optional without a predefined default so we could maybe toggle the default in the future.
// +kubebuilder:default="Endpoints" | |
// +kubebuilder:validation:Enum=Endpoints;EndpointSlice | |
ServiceDiscoveryRole string `json:"serviceDiscoveryRole,omitempty"` | |
// ServiceDiscoveryRole defines the service discovery role to use when discovering Kubernetes endpoints from ServiceMonitor objects. By default, the operator uses the `Endpoints` role. | |
// | |
// +kubebuilder:validation:Enum=Endpoints;EndpointSlice | |
// +optional | |
ServiceDiscoveryRole *string `json:"serviceDiscoveryRole,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that be a breaking change anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what Simon meant from the suggested change is:
- If users don't set ServiceDiscoveryRole, or set it as Endpoints, we use Endpoints
- Only if users set it as EndpointSlice, we use EndpointSlice
This way I don't think it would break current users' setup? Since we're already using Endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I also understood that we want to change to EndpoitSlice by default in the future 😬. I was wondering how safe this change would be if we ever happen to make it.
But that's a problem for a future PR, going forward with Endpoints by default sounds the correct approach here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think how safe that change would be depends very much on how popular EndpointSlice would be. I researched this a bit (for ServiceMonitor support in GSoC proposal). There're questions around when/whether Kubernetes can deprecate Endpoints, since EndpointSlice has already proved to perform better.
If some far day Endpoints is not used anymore (or very rarely used), I think we can safely make EndpointSlice as the default.
@@ -68,7 +68,7 @@ type ConfigGenerator struct { | |||
} | |||
|
|||
// NewConfigGenerator creates a ConfigGenerator for the provided Prometheus resource. | |||
func NewConfigGenerator(logger log.Logger, p monitoringv1.PrometheusInterface, endpointSliceSupported bool) (*ConfigGenerator, error) { | |||
func NewConfigGenerator(logger log.Logger, p monitoringv1.PrometheusInterface, endpointSliceSupported *bool) (*ConfigGenerator, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change from a bool value to a bool pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's not necessary.
Before I thought we needed to check the value of ServiceDiscoveryRole
inside NewConfigGenerator()
. If ServiceDiscoveryRole != "EndpointSlice"
then we needed to change endpointSliceSupported = false
(it may have been true
before). That was why I changed the type of endpointSliceSupported
to a bool pointer.
But now rereading the code I realized we can also check the value of ServiceDiscoveryRole
and finalize the value of endpointSliceSupported
inside sync()
in Prometheus/Prometheus Agent operator, right before calling NewConfigGenerator()
. So no need to make endpointSliceSupported
a bool pointer anymore.
Description
First task of the remaining tasks to support EndpointSlice, as discussed in #3862 (comment)
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
x
in the box that apply.CHANGE
(fix or feature that would cause existing functionality to not work as expected)FEATURE
(non-breaking change which adds functionality)BUGFIX
(non-breaking change which fixes an issue)ENHANCEMENT
(non-breaking change which improves existing functionality)NONE
(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Changelog entry
Allow users to choose Endpoints/EndpoinSlice role in Prometheus and Prometheus Agent