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

Disable nodeport auto allocation #544

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions topo/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ func (n *Impl) CreateService(ctx context.Context) error {
"app": n.Name(),
},
Type: "LoadBalancer",
// Do not allocate a NodePort for this LoadBalancer. MetalLB
// or the equivalent load balancer should handle exposing this service.
// Large topologies may try to allocate more NodePorts than are
// supported in default clusters.
// https://kubernetes.io/docs/concepts/services-networking/service/#load-balancer-nodeport-allocation
AllocateLoadBalancerNodePorts: pointer.Bool(false),
},
}
sS, err := n.KubeClient.CoreV1().Services(n.Namespace).Create(ctx, s, metav1.CreateOptions{})
Expand Down
11 changes: 7 additions & 4 deletions topo/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
kfake "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/rest"
"k8s.io/utils/pointer"
)

func NewNR(impl *Impl) (Node, error) {
Expand Down Expand Up @@ -252,8 +253,9 @@ func TestService(t *testing.T) {
TargetPort: intstr.FromInt(22),
NodePort: 0,
}},
Selector: map[string]string{"app": "dev1"},
Type: "LoadBalancer",
Selector: map[string]string{"app": "dev1"},
Type: "LoadBalancer",
AllocateLoadBalancerNodePorts: pointer.Bool(false),
},
}},
}, {
Expand Down Expand Up @@ -297,8 +299,9 @@ func TestService(t *testing.T) {
TargetPort: intstr.FromInt(9339),
NodePort: 0,
}},
Selector: map[string]string{"app": "dev2"},
Type: "LoadBalancer",
Selector: map[string]string{"app": "dev2"},
Type: "LoadBalancer",
AllocateLoadBalancerNodePorts: pointer.Bool(false),
},
}},
}, {
Expand Down
Loading