Skip to content

Commit

Permalink
Use nodeSelector for predictable IP address allocation
Browse files Browse the repository at this point in the history
Allocate IP addresses only for nodes that runs the octavia services.

JIRA: OSPRH-11747
  • Loading branch information
gthiemonge committed Dec 4, 2024
1 parent 3102aab commit 135d5b7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/octavia_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"

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

nodes, err := helper.GetKClient().CoreV1().Nodes().List(ctx, metav1.ListOptions{})
listOpts := metav1.ListOptions{}
if instance.Spec.NodeSelector != nil {
listOpts.LabelSelector = k8s_labels.Set(*instance.Spec.NodeSelector).String()
}
nodes, err := helper.GetKClient().CoreV1().Nodes().List(ctx, listOpts)
if err != nil {
return ctrl.Result{}, err
}
Expand Down

0 comments on commit 135d5b7

Please sign in to comment.