Skip to content

Commit 1a6e1b7

Browse files
committed
Use nodeSelector for predictable IP address allocation
Allocate IP addresses only for nodes that run the octavia services. JIRA: OSPRH-11747
1 parent 3102aab commit 1a6e1b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/octavia_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import (
5353
rbacv1 "k8s.io/api/rbac/v1"
5454

5555
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
56+
k8s_labels "k8s.io/apimachinery/pkg/labels"
5657
"k8s.io/apimachinery/pkg/runtime"
5758
"k8s.io/client-go/kubernetes"
5859
ctrl "sigs.k8s.io/controller-runtime"
@@ -787,7 +788,11 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
787788
// * do we want to provide a mechanism to temporarily disabling this list
788789
// for maintenance windows where nodes might be "coming and going"
789790

790-
nodes, err := helper.GetKClient().CoreV1().Nodes().List(ctx, metav1.ListOptions{})
791+
listOpts := metav1.ListOptions{}
792+
if instance.Spec.NodeSelector != nil {
793+
listOpts.LabelSelector = k8s_labels.Set(*instance.Spec.NodeSelector).String()
794+
}
795+
nodes, err := helper.GetKClient().CoreV1().Nodes().List(ctx, listOpts)
791796
if err != nil {
792797
return ctrl.Result{}, err
793798
}

0 commit comments

Comments
 (0)