Skip to content

Commit e0f70e3

Browse files
Merge pull request #423 from gthiemonge/fix_node_selector
Use nodeSelector for predictable IP address allocation
2 parents 3102aab + 74de699 commit e0f70e3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

MANAGEMENT_NETWORK.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,24 @@ The `fixed_ips`, `device_id` and `device_owner` are all of interest:
316316
* `fixed_ips` will match the IP for the `interfaces_info` of the `octavia-link-router`
317317
* `device_id` will match the ID for the `octavia-link-router`
318318
* `device_owner` indicates that OpenStack is using the port as a router interface
319+
320+
## Running the Octavia Amphora Controller Pods on specific Nodes
321+
322+
By default, the Amphora Controller pods are deployed on all the nodes of a
323+
cluster. In case of a cluster with a high number of nodes, it's not needed,
324+
it's preferable to use only 3 nodes.
325+
An admin can limit the number of instances of these services by using
326+
a `nodeSelector`. They add a label on specific nodes to indicate that they will
327+
host the Octavia services.
328+
329+
For instance, set a label on master-2:
330+
331+
```shell
332+
$ oc patch nodes master-2 --type merge --patch '{"metadata":{"labels":{"openstack.org/octavia-controller":""}}}'
333+
```
334+
335+
Make the Octavia services run only on these nodes:
336+
337+
```shell
338+
$ oc patch -n openstack openstackcontrolplane controlplane --type merge --patch '{"spec":{"octavia":{"template":{"nodeSelector":{"openstack.org/octavia-controller":""}}}}}'
339+
```

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)