-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
pkg/metrics: Allow multi port metrics Service creation #1560
pkg/metrics: Allow multi port metrics Service creation #1560
Conversation
de72be8
to
13c609c
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.
I think this is good from a code prespective. I just have 1 question about the MetricsService type.
WDYT of just using the ServicePort type there?
My reasoning behind is to make it easy for users to create the Services, I think those that know how to fill in the ServicePort (e.g. the TargetPort, NodePort, etc.) can create the Service themselves. This is meant to serve users that want to expose additional metrics endpoints, we had a bunch of requests for that, and our metrics endpoints. But am opening to that idea if everyone else thinks so, of course! |
d3907da
to
8b3f495
Compare
I would tend to agree with Shawn that the // Add to the below struct any other metrics ports you want to expose.
servicePorts := []corev1.ServicePort{
{ Name: metrics.CRPortName, TargetPort: intstr.FromInt(int(metricsPort))},
}
// Create Service object to expose the metrics port(s).
_, err = metrics.CreateMetricsService(ctx, servicePorts) To me, that seems simple enough for new users and also slightly more useful for users looking to do something slightly more custom for their metrics service ports. |
524725e
to
dfcaafc
Compare
@joelanford @shawn-hurley I made the suggested change, the additional fields were needed otherwise Service cannot be created. PTAL. |
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.
Can you update the CHANGELOG and mention the removed PrometheusPortName
and ExposeMetricsPort
identifiers, and the added OperatorPortName
, CRPortName
, and CreateMetricsService
identifiers?
@hasbro17 Is there a migration guide that needs to mention this change?
internal/pkg/scaffold/cmd.go
Outdated
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||
"sigs.k8s.io/controller-runtime/pkg/runtime/signals" | ||
"k8s.io/apimachinery/pkg/util/intstr" |
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.
This is a duplicate of line 62, so it can be removed.
@joelanford Still working on the migration guide but yes for |
dfcaafc
to
323eb1d
Compare
323eb1d
to
1e789cb
Compare
@hasbro17 @joelanford I added things to the CHANGELOG, please have a look at that, if the wording is clear enough, thanks! |
/test marker |
No idea why marker test is failing here, as the URLs work for me 🤔 |
/test marker |
CHANGELOG.md
Outdated
|
||
### Deprecated | ||
|
||
### Removed | ||
|
||
- The SDK no longer depends on a `vendor/` directory to manage dependencies *only if* using [Go modules](https://github.com/golang/go/wiki/Modules). The SDK and operator projects will only use vendoring if using `dep`, or modules and a `vendor/` dir is present. ([#1519](https://github.com/operator-framework/operator-sdk/pull/1519)) | ||
- `ExposeMetricsPort` is now depracted and was replaced with `CreateMetricsService()` function. `PrometheusPortName` constant is replaced with `OperatorPortName`. ([#1560](https://github.com/operator-framework/operator-sdk/pull/1560)) |
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.
Deprecated means that the thing still exists and will be removed in a future version, right? In this PR, we're actually removing it without deprecating it.
So that leads me to a question: should we actually deprecate ExposeMetricsPort
and leave it in place for now?
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 are pre 1.0
I think it is ok to deprecate and replace in a single release IMO. WDYT?
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 we said we are making breaking changes until the 1.0 release yes.
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.
Maybe we could make it more in bold in the CHANGELOG? Also with the migration doc coming up that you mention @joelanford it should be easy for people to migrate IMO.
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, I think it's fine to remove it. Just wanted to make sure we were all in agreement to do that. I would suggest:
- Prefixing with
**Breaking change**:
like we've done before s/deprecated/removed/
to make it clear theExposeMetricsPort
is no longer present.
WDYT?
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.
sgtm, done!
/retest |
This allows users to pass in any metrics port and we expose that port in one Service. With that we also expose the custom resource metrics port.
1e789cb
to
f40564a
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.
/approve
Motivation for the change:
With the recent addition of Custom Resource metrics we need to expose the port in the metrics Service. This also helps users who want to expose their own metrics ports in a Service as they can just pass in another port.
Note: We also changed the name of the Service that is being created by appending
-metrics
to the operator name, this makes it self descriptive as we did have questions what is this service for.TODO: