Repository navigation
Add auto IP family detection for LoadBalancer Service - #5530
Conversation
|
Hi @tanayarun! Welcome to the project! 🎉 Thanks for opening this pull request! |
|
✅ All required contributors have signed the F5 CLA for this PR. Thank you! |
|
I have hereby read the F5 CLA and agree to its terms |
b6c4496 to
7c8a623
Compare
|
Thanks again @tanayarun for this contribution. I'll give this PR a full review today. |
|
Hi @tanayarun After going through the PR, I think we might be able to simplify the approach. Right now, the new With that, we don't really need So, in // IPFamily specifies the IP family to be used by the NGINX.
// If not set, NGF inspectes the `default/kubernetes` service's `ipFamily` field at startup
// to obtain the IP family of the cluster and configure NGINX accordingly.
//
// +optional
IPFamily *IPFamilyType `json:"ipFamily,omitempty"`Your new function, This would look like this in func (p *NginxProvisioner) setIPFamily(nProxyCfg *graph.EffectiveNginxProxy, svc *corev1.Service) {
// If the user explicitly set ipFamily, use that
// Otherwise use auto-detected ipFamily from cluster
ipFamily := p.clusterIPFamily
if nProxyCfg != nil && nProxyCfg.IPFamily != nil {
ipFamily = *nProxyCfg.IPFamily
}
...Let me know what you think too, and if anything I said make sense. |
|
That makes sense and is cleaner, using |
|
Implemented as suggested. |
Thanks @tanayarun I'll run some local tests on this now. |
|
Hey @shaun-nx. Unfortunately I don't have access to a MetalLB cluster to test end-to-end, |
No problem at all @tanayarun ! |
|
Yes, the contributing guide were really helpful. |
|
Changes looks to be good from what I've tested. Nice work @tanayarun ! Also, aside from making the new test, the existing If you add this line to the end of g.Expect(provisioner.clusterIPFamily).To(Equal(ngfAPIv1alpha2.Dual)) |
|
I added the assertion to |
Ah yeah, that's a good point. I was worried that we needed a test which created the kubernetes service, but I see your test does that too. So that should be fine. |
|
Let me know when you've pushed the changes with the new test assertion. I'll approve the change then. Nice work 😄 |
|
Sorry for the delay, I will do it asap. |
32bab6b to
94bcd01
Compare
|
Hey, @shaun-nx I have pushed the changes ! |
50e0c4b to
3b7c556
Compare
|
Hey @shaun-nx , I have been working on this and I am almost finished, I will push the changes soon |
01969bf to
ff30a6c
Compare
|
Hey @shaun-nx. |
shaun-nx
left a comment
There was a problem hiding this comment.
Just finished re testing this locally. Everything looks to be working find.
Great job with this @tanayarun !
e00dda9 to
2cdb696
Compare
…vice configuration
…re cache is ready
72f4d38 to
726ad46
Compare
Proposed changes
Problem: NGF always sets
ipFamilyPolicy: PreferDualStackon the generatedLoadBalancer Service regardless of cluster capability, causing unnecessary
error noise in MetalLB on IPv4 only clusters.
Solution: Added a new
IPFamilyTypevalueauto(now the default, replacingdual) that detects the cluster's IP family at startup by readingspec.ipFamiliesfrom thekubernetesService inkube-system. The detectedvalue is stored on
NginxProvisionerand used whenipFamilyisauto.Explicit
ipFamily: dual/ipv4/ipv6values are always respected and overrideauto-detection.
Testing: Added
TestDetectClusterIPFamilycovering IPv4-only, dual-stack, andnot found fallback cases. Updated
TestSetIPFamilyto cover theautopath.All existing unit tests pass.
Closes #5488
Checklist
Release notes