-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Hey there!
Apologies for the delayed follow-up — I was abroad last week and didn’t have the chance to test the fix for #1061. I’ve now updated my Kamaji deployment to the latest version, and the original issue appears to be resolved. Thanks for that!
However, I’ve come across a small caveat that may need further attention. When using Gateway API and configuring a parentRef with a port different from the one defined in spec.networkProfile.port, the generated kubeconfig contains an incorrect server value. Specifically, it uses the port from spec.networkProfile.port instead of the port specified in the Gateway’s parentRef.
After reviewing the source code, I believe this behavior originates here:
kamaji/internal/resources/kubeadm_config.go
Lines 93 to 106 in 309d988
| endpoint := net.JoinHostPort(address, strconv.FormatInt(int64(port), 10)) | |
| spec := tenantControlPlane.Spec.ControlPlane | |
| if spec.Gateway != nil { | |
| if len(spec.Gateway.Hostname) > 0 { | |
| gaddr, gport := utilities.GetControlPlaneAddressAndPortFromHostname(string(spec.Gateway.Hostname), port) | |
| endpoint = net.JoinHostPort(gaddr, strconv.FormatInt(int64(gport), 10)) | |
| } | |
| } | |
| if spec.Ingress != nil { | |
| if len(spec.Ingress.Hostname) > 0 { | |
| iaddr, iport := utilities.GetControlPlaneAddressAndPortFromHostname(spec.Ingress.Hostname, port) | |
| endpoint = net.JoinHostPort(iaddr, strconv.FormatInt(int64(iport), 10)) | |
| } | |
| } |
For the Ingress resource, the current implementation works correctly because both hostname and port are embedded in the same field and can be extracted using utilities.GetControlPlaneAddressAndPortFromHostname. However, this approach doesn’t apply to the Gateway resource, since the port must instead be retrieved from the parentRef field in the spec.
Given that gateway.parentRefs is a slice and multiple references can be defined, I’m unsure of what the cleanest or most appropriate solution would be in this case.
I’d appreciate your thoughts on this.
Thank you for your time!