Skip to content

BUG/MEDIUM: preserve NodePort when reconciling Service ports#21

Open
pierrecdn wants to merge 1 commit intohaproxytech:devfrom
criteo-forks:fix/preserve-nodeport-on-reconcile
Open

BUG/MEDIUM: preserve NodePort when reconciling Service ports#21
pierrecdn wants to merge 1 commit intohaproxytech:devfrom
criteo-forks:fix/preserve-nodeport-on-reconcile

Conversation

@pierrecdn
Copy link
Copy Markdown
Contributor

Hey team,

At trying to migrate my previous install (0.8) to the Helm chart and 1.0.2, I noticed this behavior associated to the use of statically defined nodePorts, that actually prevented me to complete the said migration.

Typically my HUG Service is constantly updated with dynamically computed NodePorts, which obviously isn't expected 😅.


The Service port reconciler rebuilds .spec.ports from VirtualListeners on every event batch.
VirtualListener-derived ports are emitted with no NodePort, so for Services of type NodePort the patch resets NodePort to 0 and Kubernetes re-allocates a random one on every reconcile. That makes the chart's NodePort defaults and any user-supplied nodePort from service.extraPorts effectively useless.

This commit carry the existing NodePort through whenever the port number matches. That should cover both the steady-state case (preserve what Kubernetes allocated on the first reconcile) and the pre-seeded case (keep a user-provided nodePort when the chart-created Service's port number matches a Gateway listener, even if the port names differs).

The Service port reconciler rebuilds .spec.ports from VirtualListeners
on every event batch.
VirtualListener-derived ports are emitted with no NodePort, so for
Services of type NodePort the patch resets NodePort to 0 and
Kubernetes re-allocates a random one on every reconcile. That makes
the chart's NodePort defaults and any user-supplied nodePort from
service.extraPorts effectively useless.

This commit carry the existing NodePort through whenever the port
number matches. That should cover both the steady-state case
(preserve what Kubernetes allocated on the first reconcile) and the
initial-state case (keep a user-provided nodePort when the
chart-created Service's port number matches a Gateway listener, even
if the port names differs).

Signed-off-by: Pierre Cheynier <p.cheynier@criteo.com>
@pierrecdn pierrecdn force-pushed the fix/preserve-nodeport-on-reconcile branch from caa55f0 to 944ffaa Compare April 24, 2026 13:23
@hdurand0710
Copy link
Copy Markdown
Member

@pierrecdn Thanks for your contribution.
LGTM

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.

2 participants