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

feat: support Selectors field in kubernetes SD #6053

Merged
merged 1 commit into from Nov 3, 2023

Conversation

slashpai
Copy link
Contributor

Related-to #5711

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.

feat: support Selectors field in kubernetes SD

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.

feat: support Selectors field in kubernetes SD

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

SelectScrapeConfigs() needs to validate the field and label selectors too.

Role string `json:"role"`
Role K8SRole `json:"role"`
// Selector to select objects.
Selectors []K8SSelectorConfig `json:"selectors,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

there can be only one item in the list for the same role.

Suggested change
Selectors []K8SSelectorConfig `json:"selectors,omitempty"`
// +optional
// +listType=map
// +listMapKey=role
Selectors []K8SSelectorConfig `json:"selectors,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simonpasquier do we want to specify a default here since selectors is not required field?

 main_test.go:184: initialize ScrapeConfig v1alpha1 CRD: create CRD scrapeconfigs on the apiserver: create CRD ScrapeConfig: CustomResourceDefinition.apiextensions.k8s.io "scrapeconfigs.monitoring.coreos.com" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[kubernetesSDConfigs].items.properties[selectors].items.properties[role].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property

pkg/apis/monitoring/v1alpha1/scrapeconfig_types.go Outdated Show resolved Hide resolved
pkg/prometheus/promcfg.go Outdated Show resolved Hide resolved
@slashpai
Copy link
Contributor Author

@simonpasquier addressed review comments

@slashpai slashpai force-pushed the node-discovery branch 2 times, most recently from 9854ef8 to b82ed76 Compare October 31, 2023 18:04
Related-to prometheus-operator#5711

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@slashpai
Copy link
Contributor Author

slashpai commented Nov 3, 2023

@simonpasquier addressed the issue. Could you please review again

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks!

@simonpasquier simonpasquier merged commit fca0075 into prometheus-operator:main Nov 3, 2023
17 checks passed
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

2 participants