Repository: k3s-io/k3s
File: pkg/cloudprovider/servicelb.go (Go)

Code before:
	servicehelper "k8s.io/cloud-provider/service/helpers"
	"k8s.io/kubernetes/pkg/features"
	utilsnet "k8s.io/utils/net"
	utilsptr "k8s.io/utils/ptr"
)

var (
	finalizerName          = "svccontroller." + version.Program + ".cattle.io/daemonset"
	svcNameLabel           = "svccontroller." + version.Program + ".cattle.io/svcname"
	svcNamespaceLabel      = "svccontroller." + version.Program + ".cattle.io/svcnamespace"
	daemonsetNodeLabel     = "svccontroller." + version.Program + ".cattle.io/enablelb"
	daemonsetNodePoolLabel = "svccontroller." + version.Program + ".cattle.io/lbpool"
	nodeSelectorLabel      = "svccontroller." + version.Program + ".cattle.io/nodeselector"
	priorityAnnotation     = "svccontroller." + version.Program + ".cattle.io/priorityclassname"
	tolerationsAnnotation  = "svccontroller." + version.Program + ".cattle.io/tolerations"
	controllerName         = names.ServiceLBController
)

const (
	Ready                      = condition.Cond("Ready")
	DefaultLBNS                = meta.NamespaceSystem
	DefaultLBPriorityClassName = "system-node-critical"
)

var (
	DefaultLBImage = "registry.suse.com/bci/bci-busybox:latest"
)

func (k *k3s) Register(ctx context.Context,
	nodes coreclient.NodeController,
	pods coreclient.PodController,
	endpointslices discoveryclient.EndpointSliceController,
) error {
	nodes.OnChange(ctx, controllerName, k.onChangeNode)
	pods.OnChange(ctx, controllerName, k.onChangePod)
	endpointslices.OnChange(ctx, controllerName, k.onChangeEndpointSlice)

	if err := k.ensureServiceLBNamespace(ctx); err != nil {
		return err
	}

	if err := k.ensureServiceLBServiceAccount(ctx); err != nil {
		return err
	}

	go wait.Until(k.runWorker, time.Second, ctx.Done())

	return k.removeServiceFinalizers(ctx)
}

// ensureServiceLBNamespace ensures that the configured namespace exists.

Review comment (suggestion):
Don't use the `latest` tag, and this needs to come from something in the `rancher/mirrored-` images alongside everything else.

Code after:
	servicehelper "k8s.io/cloud-provider/service/helpers"
	"k8s.io/kubernetes/pkg/features"
	utilsnet "k8s.io/utils/net"
	utilsptr "k8s.io/utils/ptr"
)

var (
	finalizerName          = "svccontroller." + version.Program + ".cattle.io/daemonset"
	svcNameLabel           = "svccontroller." + version.Program + ".cattle.io/svcname"
	svcNamespaceLabel      = "svccontroller." + version.Program + ".cattle.io/svcnamespace"
	daemonsetNodeLabel     = "svccontroller." + version.Program + ".cattle.io/enablelb"
	daemonsetNodePoolLabel = "svccontroller." + version.Program + ".cattle.io/lbpool"
	nodeSelectorLabel      = "svccontroller." + version.Program + ".cattle.io/nodeselector"
	extTrafficPolicyLabel  = "svccontroller." + version.Program + ".cattle.io/exttrafficpolicy"
	priorityAnnotation     = "svccontroller." + version.Program + ".cattle.io/priorityclassname"
	tolerationsAnnotation  = "svccontroller." + version.Program + ".cattle.io/tolerations"
	controllerName         = names.ServiceLBController
)

const (
	Ready                      = condition.Cond("Ready")
	DefaultLBNS                = meta.NamespaceSystem
	DefaultLBPriorityClassName = "system-node-critical"
)

var (
	DefaultLBImage = "rancher/mirrored-library-busybox:1.36.1"
)

func (k *k3s) Register(ctx context.Context,
	nodes coreclient.NodeController,
	pods coreclient.PodController,
	endpointslices discoveryclient.EndpointSliceController,
) error {
	nodes.OnChange(ctx, controllerName, k.onChangeNode)
	pods.OnChange(ctx, controllerName, k.onChangePod)
	endpointslices.OnChange(ctx, controllerName, k.onChangeEndpointSlice)

	if err := k.ensureServiceLBNamespace(ctx); err != nil {
		return err
	}

	if err := k.ensureServiceLBServiceAccount(ctx); err != nil {
		return err
	}

	go wait.Until(k.runWorker, time.Second, ctx.Done())

	return k.removeServiceFinalizers(ctx)
}