Skip to content

feat(init): enable switching between nodeport and proxy mode#4608

Open
AustinAbro321 wants to merge 12 commits intomainfrom
nodeport-to-proxy-mode
Open

feat(init): enable switching between nodeport and proxy mode#4608
AustinAbro321 wants to merge 12 commits intomainfrom
nodeport-to-proxy-mode

Conversation

@AustinAbro321
Copy link
Member

@AustinAbro321 AustinAbro321 commented Feb 17, 2026

Description

This allows switching between nodeport and proxy mode. When a user runs a secondary zarf init, if no mode is specified, then the mode that this currently in Zarf state will be used. If a mode is specified, then that mode will be used instead

Related Issue

Fixes #4586

Checklist before merging

@netlify
Copy link

netlify bot commented Feb 17, 2026

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 1c0e873
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/69aeb53efe45bf0008cf3fbf

Signed-off-by: Austin Abro <austinabro321@gmail.com>
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 31.37255% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pkg/state/state.go 0.00% 20 Missing ⚠️
src/pkg/cluster/cluster.go 64.00% 6 Missing and 3 partials ⚠️
src/cmd/initialize.go 0.00% 6 Missing ⚠️
Files with missing lines Coverage Δ
src/cmd/initialize.go 25.65% <0.00%> (-0.55%) ⬇️
src/pkg/cluster/cluster.go 32.56% <64.00%> (+0.79%) ⬆️
src/pkg/state/state.go 27.53% <0.00%> (-2.43%) ⬇️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AustinAbro321 and others added 9 commits February 17, 2026 10:16
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@AustinAbro321 AustinAbro321 marked this pull request as ready for review February 17, 2026 20:36
@AustinAbro321 AustinAbro321 requested review from a team as code owners February 17, 2026 20:36
@AustinAbro321 AustinAbro321 changed the title feat: enable switching between nodeport and proxy mode feat(init): enable switching between nodeport and proxy mode Feb 20, 2026
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

One observation - otherwise documentation for switching from one to another as a supported operation could be helpful if not currently planned.

}

// CheckIfCredsChanged compares two RegistryInfo structs and returns true if any non-empty fields have changed
func CheckIfCredsChanged(existing, given RegistryInfo) bool {
Copy link
Member

Choose a reason for hiding this comment

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

This does not check NodePort - whereas it would have before. Which is intentional in the context of running zarf init and changing the mode from nodeport to proxy.

But does/should a nodeport to nodeport upgrade with a nodeport change silently pass here now? Should we establish a check back in the caller for this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it does pass where it didn't before, but I think that's a benefit. I don't think there's an advantage to stopping the update of the nodeport. I believe the historical reason we did this is because it was more convenient to use helpers.IsNotZeroAndNotEqual instead of a custom function I created here

Copy link
Member

Choose a reason for hiding this comment

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

That sounds fair. If the nodeport is updated - do we ever hit a scenario where an artifact can not be pulled due to a change in the registry service? Everything GitOps pulls from the internal service (so we're fine there). Pods should be maintained by a cache on the node until another mutation request is sent to update the host.

Copy link
Member Author

Choose a reason for hiding this comment

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

Zarf and the kubelet won't because of the situation you described. If the user has something else pulling from the nodeport (discouraged outside of the kubelet case) it's possible, but since the user is opting into the nodeport change, I think that's reasonable.

@github-project-automation github-project-automation bot moved this to In progress in Zarf Mar 4, 2026
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

minor comments - an interesting side effect I didn't see mentioned is that deploying nodeport -> proxy -> nodeport looks to have retained the mtls settings on the nodeport solution. I am thinking about the implications here but I also don't know if this was intended to be a fully supported workflow. Documentation here would be useful - to include the upgrade support on init such that you do not need to re-declare your previous mode.

}

// CheckIfRegistryCredsChanged compares two RegistryInfo structs and returns true if any non-empty fields have changed
func CheckIfRegistryCredsChanged(existing, given RegistryInfo) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Slightly misleading function name. We include Address in the comparison but not NodePort or Mode. So it is not strictly creds nor is it a comparison for potential drift between two RegistryInfo Structs (See doccomment).

o.registryInfo.RegistryMode = state.RegistryModeExternal
}

if o.registryInfo.NodePort == 0 && o.registryInfo.RegistryMode == state.RegistryModeNodePort {
Copy link
Member

Choose a reason for hiding this comment

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

Initially this feels duplicative of something that could occur in FillInEmptyValues but in tracing I see that this is needed for InitState's opts.RegistryInfo.NodePort != 0 guard to work on mode switches.

This works in the given state but feels a little confusing. My only thought is that being able to discern empty from go default could be handy - but I don't know if we want to change the surface of those fields now... (thinking *int).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Switch between nodeport and registry proxy mode

2 participants