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

⚠ Introduce Metrics Options struct & secure metrics serving #2407

Merged
merged 1 commit into from Aug 11, 2023

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Jul 15, 2023

This PR introduces metrics options on the manager options. Via the new metrics options it will now be possible to serve metrics via tls and to use authentication and authorization.

  • Metrics.FilterProvider allows to provide a metrics filter.
    • filters.WithAuthenticationAndAuthorization is a builtin filter that implements authentication and authorization
  • Metrics.SecureServing enables serving metrics on https
    • This is necessary for the above filter because tokens for authentication should not be sent via http
  • Metrics.ExtraHandlers makes it possible to specify the extra handlers directly on the options. manager.AddMetricsExtraHandler has been removed.

Fixes #2073

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 15, 2023
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 15, 2023
@sbueringer sbueringer changed the title ⚠ Implement secure metrics serving [WIP] ⚠ Implement secure metrics serving Jul 15, 2023
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2023
@sbueringer
Copy link
Member Author

sbueringer commented Jul 15, 2023

@alvaroaleman @vincepri
I think this should be ready for a first round of review & discussion.

After that I'll add more documentation and add / fix unit tests.

pkg/manager/internal.go Outdated Show resolved Hide resolved
pkg/manager/manager.go Outdated Show resolved Hide resolved
@sbueringer sbueringer changed the title [WIP] ⚠ Implement secure metrics serving [WIP] ✨ Implement secure metrics serving Jul 17, 2023
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 17, 2023
@sbueringer sbueringer force-pushed the pr-auth-metrics branch 2 times, most recently from 1504d8f to 66ae79b Compare July 17, 2023 20:20
@sbueringer sbueringer changed the title [WIP] ✨ Implement secure metrics serving ✨ Implement secure metrics serving Jul 17, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2023
@sbueringer
Copy link
Member Author

@alvaroaleman Thx for the review. Changed the defaulting behavior and added test coverage

@sbueringer
Copy link
Member Author

@vincepri PTAL when you have some time :)

@sbueringer
Copy link
Member Author

Refactored the implementation to avoid introducing a dependency to k8s.io/apiserver for folks who are not using the authentication/authorization

pkg/manager/internal.go Outdated Show resolved Hide resolved
@sbueringer sbueringer force-pushed the pr-auth-metrics branch 3 times, most recently from 4b2e71f to 4aa927f Compare July 24, 2023 05:55
@sbueringer sbueringer changed the title ✨ Implement secure metrics serving ⚠ Implement secure metrics serving Jul 24, 2023
pkg/metrics/filters/filters.go Outdated Show resolved Hide resolved
pkg/metrics/listener.go Outdated Show resolved Hide resolved
pkg/manager/manager.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 25, 2023
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 5, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 5, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 10, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 10, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 23, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 27, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 27, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 27, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Jan 27, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Feb 2, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Feb 2, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
lleshchi added a commit to lleshchi/hive that referenced this pull request Feb 8, 2024
Fix breaking changes from upgrade of controller-runtime.

Breaking changes from:
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.16.0
- kubernetes-sigs/controller-runtime#2407
- kubernetes-sigs/controller-runtime#2416

HIVE-2254

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add authorization for metrics endpoint
4 participants