Skip to content
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[#5345]: RoleSelector field in ServiceMonitor (#5345) #6580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yp969803
Copy link
Contributor

Description

If it fixes a bug or resolves a feature request, be sure to link to that issue. #5345

Be able to define selectors in kubernetes_sd_config

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

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.


@yp969803 yp969803 requested a review from a team as a code owner May 12, 2024 20:55
@@ -75,7 +75,12 @@ type ServiceMonitorSpec struct {
Endpoints []Endpoint `json:"endpoints"`

// Label selector to select the Kubernetes `Endpoints` objects.
Selector metav1.LabelSelector `json:"selector"`
EndpointsSelector metav1.LabelSelector `json:"endpointsSelector"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to rename an existing field.


// Role specifies the role of the Kubernetes resources to be selected.
// Possible values for Role are: "endpoints", "endpointslice", "service", "pod", "node", or "ingress".
Role string `json:"role" protobuf:"bytes,1,opt,name=role"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the protobuf tag.


// Selector is a list of RoleSelector.
// +optional
Selector []RoleSelector `json:"selector"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect label/field selectors to be defined in the Endpoint field.

type RoleSelector struct {

// Role specifies the role of the Kubernetes resources to be selected.
// Possible values for Role are: "endpoints", "endpointslice", "service", "pod", "node", or "ingress".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add validation markers.

@ArthurSens
Copy link
Member

Hey, I've read the linked issue but I couldn't understand why we would want different roles in ServiceMonitors that are not Endpoint or EndpointSlice. (Already being worked on in #6518)

I.e., if we're already using the Endpoint role (SM's default role), for example, why would we use a selector using a different role?

@yp969803
Copy link
Contributor Author

@ArthurSens, agree with you, actually, i have taken referenced from the prometheus doc https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config

@yp969803
Copy link
Contributor Author

@ArthurSens @simonpasquier i have changed the things, can you look into the commit is I am going correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants