Skip to content

Commit b6684ee

Browse files
committed
优化:自动创建 CLB 时,根据maxPod,minPort,maxPort以及当前配额限制智能判断需要的 CLB 数量
1 parent 77699dc commit b6684ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/controller/dedicatedclbservice_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ func (r *DedicatedCLBServiceReconciler) sync(ctx context.Context, ds *networking
221221
}
222222
}
223223
if listenerGap > 0 {
224-
lbNum := float64(listenerGap) / (float64(ds.Spec.MaxPort) - float64(ds.Spec.MinPort) + 1)
224+
podLimit := listenerQuota
225+
if maxPorts := ds.Spec.MaxPort - ds.Spec.MinPort + 1; maxPorts < podLimit {
226+
podLimit = maxPorts
227+
}
228+
if ds.Spec.MaxPod != nil && *ds.Spec.MaxPod < podLimit {
229+
podLimit = *ds.Spec.MaxPod
230+
}
231+
lbNum := float64(listenerGap) / float64(podLimit)
225232
lbToCreate := int(math.Ceil(lbNum))
226233
r.Recorder.Event(ds, corev1.EventTypeNormal, "CreateCLB", fmt.Sprintf("clb is not enough, try to create clb instance (num: %d)", lbToCreate))
227234
if err := r.allocateNewCLB(ctx, ds, lbToCreate); err != nil {

0 commit comments

Comments
 (0)