-
Notifications
You must be signed in to change notification settings - Fork 459
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
feat(TargetAllocator): allow configuration of PrometheusCR namespaceSelectors #3573
base: main
Are you sure you want to change the base?
feat(TargetAllocator): allow configuration of PrometheusCR namespaceSelectors #3573
Conversation
a40ec60
to
8721b68
Compare
712162d
to
a539185
Compare
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.
Change looks good overall, just one thought on how to prevent it from breaking. cc @swiatekm
prometheusCRConfig["service_monitor_selector"] = taSpec.PrometheusCR.ServiceMonitorSelector | ||
|
||
prometheusCRConfig["service_monitor_namespace_selector"] = taSpec.PrometheusCR.ServiceMonitorNamespaceSelector | ||
|
||
prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector | ||
|
||
prometheusCRConfig["pod_monitor_namespace_selector"] = taSpec.PrometheusCR.PodMonitorNamespaceSelector | ||
|
||
prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector | ||
|
||
prometheusCRConfig["scrape_config_namespace_selector"] = taSpec.PrometheusCR.ScrapeConfigNamespaceSelector | ||
|
||
prometheusCRConfig["probe_selector"] = taSpec.PrometheusCR.ProbeSelector | ||
|
||
prometheusCRConfig["probe_namespace_selector"] = taSpec.PrometheusCR.ProbeNamespaceSelector | ||
|
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.
suggestion: we can remove the excess spacing here, it's superfluous IMO.
// matchExpressions are ANDed. An empty label selector matches all objects. A null | ||
// label selector matches no objects. | ||
// +optional | ||
PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,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 wonder if we should also do some defaulting here to prevent an upgrade from breaking existing installations? As the doc string states, a null selector matches nothing, upgrading with this on will mean that existing installations (who do not set this currently) would not have it, resulting in a null selector, aka 💥
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.
Great point 👍 , should we implement that for the PodMonitorNamespaceSelector
or for all the selectors (including the already existing ones) ? What do you recommend ?
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.
We should set the default to the empty selector for all selectors you're adding here. The end result will be that resource selectors target nothing by default, while namespace selectors target everything, which is also what prometheus-operator does.
I'm not sure if you can set these defaults via a kubebuilder marker. If not, then you'll have to do it in the webhook.
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.
Hey @swiatekm , thank you for the heads up for the kubebuilder 😃 I indeed found a way to set a default and I added it to the new fields like so
// +kubebuilder:default:={}
which resulted in a generated crd like this:
...
podMonitorNamespaceSelector:
default: {}
properties:
matchExpressions:
...
Let me know if that looks good for you 🙏
e2dbc42
to
4f9c31c
Compare
4f9c31c
to
db97808
Compare
Description:
Adding the possibility to set values for PrometheusCR:
probeNamespaceSelector
serviceMonitorNamespaceSelector
scrapeConfigNamespaceSelector
probeNamespaceSelector
Link to tracking Issue(s): #3086
Testing: Added tests for configmap generation
Documentation: Updated README.md