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/add support for hostPort in container #2763

Merged
merged 1 commit into from
Apr 9, 2024
Merged

feat/add support for hostPort in container #2763

merged 1 commit into from
Apr 9, 2024

Conversation

bmiguel-teixeira
Copy link
Contributor

@bmiguel-teixeira bmiguel-teixeira commented Mar 16, 2024

Description:

This PR adds supports for defining additional behavior on the ports section. More specifically, I added the hostPort field that maps to the equivalent field in the containerPort.

This allows the container to bind the hostPort when running in daemonset mode.

Link to tracking Issue(s):

Related to #2180

Testing:

Documentation:

Copy link

linux-foundation-easycla bot commented Mar 16, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: bmiguel-teixeira / name: Bruno Teixeira (52e2b5a)

@pavolloffay
Copy link
Member

@bmiguel-teixeira could you please sign the EasyCLA ?

@bmiguel-teixeira bmiguel-teixeira marked this pull request as ready for review March 18, 2024 20:40
@bmiguel-teixeira bmiguel-teixeira requested a review from a team March 18, 2024 20:40
@bmiguel-teixeira
Copy link
Contributor Author

bmiguel-teixeira commented Mar 18, 2024

Hi @pavolloffay

CLA signed.

The PR is now ready to review. Additionally, i added a quick e2e for the ports fields, however it looks like all requests are getting mutated/converted to v1alpha1 model even though the storage version is v1beta.

Looks like i caught the project in the transition to the v1beta1 version. I am unsure how you guys want to handle it?

Cheers,

@TylerHelmuth
Copy link
Member

Related to #2180

@TylerHelmuth
Copy link
Member

@bmiguel-teixeira you're gonna get slow responses from maintainers this week bc of Kubecon in Paris. I believe we'll want to include the feature to both versions since we're still releasing alpha.

@bmiguel-teixeira
Copy link
Contributor Author

Hi @TylerHelmuth @pavolloffay

v1alpah1 updated. e2e now passing.

No rush. Enjoy kubecon

@TylerHelmuth
Copy link
Member

@bmiguel-teixeira please sign the CLA

@bmiguel-teixeira
Copy link
Contributor Author

Hi @TylerHelmuth

fixed missing tests. CLA signed. Had some trouble with my commit signature.

Cheers

internal/manifests/collector/container_test.go Outdated Show resolved Hide resolved
@@ -291,6 +291,16 @@ type OpenTelemetryCollectorSpec struct {
DeploymentUpdateStrategy appsv1.DeploymentStrategy `json:"deploymentUpdateStrategy,omitempty"`
}

// PortsSpec defines the OpenTelemetryCollector's container/service ports additional specifications.
type PortsSpec struct {
Copy link
Member

Choose a reason for hiding this comment

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

This ends up being a breaking change, so maybe I was wrong when I said it should live in the alpha api. @open-telemetry/operator-maintainers can you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it? Looks like we're just adding fields to the CRDs. I'm personally a bit worried that we're reinventing the wheel with this PortSpec definition, and the community has converged on some standard for this "ContainerPort and ServicePort in one" concept.

Copy link
Member

Choose a reason for hiding this comment

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

I put my comment in the wrong spot.

Changing from Ports []v1.ServicePort json:"ports,omitempty" to Ports []PortsSpec json:"ports,omitempty" is the breaking change I was referring to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @swiatekm-sumo

While I aggree that mixing values for different reasons can be messy, the current ports definition already present in the spec is used both to populate the Service object and the ContainerPorts object.

We could do a dedicated new field or something, but then we would have multiples places for settings being used in also multiples places.

Putting in the same port context seemed the cleanest place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TylerHelmuth Can you elaborate on how this is a breaking change? the interface/spec with the client remains the same, minus the new field hostPort.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bmiguel-teixeira I agree with your approach here. My point was that this sounds like a problem other operators also had to solve, and I'm wondering if there's some de-facto standard way of doing it.

@TylerHelmuth PortsSpec embeds ServicePort, so this doesn't look like a breaking change from the perspective of a CRD user. Can you describe a specific situation where this would break someone?

Copy link
Member

Choose a reason for hiding this comment

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

I misinterpreted what ServicePort represented, I didn't realize it was a full struct. I agree this is being done in a non-breaking way.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I looked around and didn't see anything from the obvious sources...

@mattbrandman
Copy link

Was literally just looking for this feature to handle daemonset targeting, thanks!

@jaronoff97
Copy link
Contributor

@bmiguel-teixeira could you rebase when you get a chance?

@bmiguel-teixeira
Copy link
Contributor Author

hey @jaronoff97

Rebased & all checks passing.

Cheers

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

This LGTM. Going to wait on on more ✅ to merge.

@jaronoff97 jaronoff97 requested a review from swiatekm April 4, 2024 15:35
@bmiguel-teixeira
Copy link
Contributor Author

hey @swiatekm-sumo
Any comments?

Ty

@jaronoff97 jaronoff97 merged commit e399e61 into open-telemetry:main Apr 9, 2024
31 checks passed
@jaronoff97
Copy link
Contributor

@bmiguel-teixeira thank you very much for your contribution!! This will be included in the next release.

ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
rubenvp8510 pushed a commit to rubenvp8510/opentelemetry-operator that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants