servicelb pool selector

adds a new optional node label
"svccontroller.k3s.cattle.io/lbpool=<pool>" that can be set on nodes.
ServiceType: LoadBalancer services can then specify a matching label,
which will schedule the DaemonSet only on specified nodes. This allows
operators to specify different pools of nodes that can serve different
LoadBalancer services on the same ports.

Signed-off-by: robertlestak <robert.lestak@umusic.com>
pull/5205/head
robertlestak 3 years ago committed by Brad Davidson
parent 232e00dd30
commit a82ac4fdc7

@ -32,10 +32,11 @@ import (
) )
var ( var (
svcNameLabel = "svccontroller." + version.Program + ".cattle.io/svcname" svcNameLabel = "svccontroller." + version.Program + ".cattle.io/svcname"
daemonsetNodeLabel = "svccontroller." + version.Program + ".cattle.io/enablelb" daemonsetNodeLabel = "svccontroller." + version.Program + ".cattle.io/enablelb"
nodeSelectorLabel = "svccontroller." + version.Program + ".cattle.io/nodeselector" daemonsetNodePoolLabel = "svccontroller." + version.Program + ".cattle.io/lbpool"
DefaultLBImage = "rancher/klipper-lb:v0.3.4" nodeSelectorLabel = "svccontroller." + version.Program + ".cattle.io/nodeselector"
DefaultLBImage = "rancher/klipper-lb:v0.3.4"
) )
const ( const (
@ -499,6 +500,10 @@ func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
ds.Spec.Template.Spec.NodeSelector = map[string]string{ ds.Spec.Template.Spec.NodeSelector = map[string]string{
daemonsetNodeLabel: "true", daemonsetNodeLabel: "true",
} }
// Add node selector for "svccontroller.k3s.cattle.io/lbpool=<pool>" if service has lbpool label
if svc.Labels[daemonsetNodePoolLabel] != "" {
ds.Spec.Template.Spec.NodeSelector[daemonsetNodePoolLabel] = svc.Labels[daemonsetNodePoolLabel]
}
ds.Labels[nodeSelectorLabel] = "true" ds.Labels[nodeSelectorLabel] = "true"
} }
return ds, nil return ds, nil

Loading…
Cancel
Save