mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-07 11:04:44 +00:00
Add EndpointReconcilerConfig to master Config
Add EndpointReconcilerConfig to master Config to allow downstream integrators to customize the reconciler and reconciliation interval when starting a customized master.
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
@@ -237,6 +238,12 @@ func TestFindExternalAddress(t *testing.T) {
|
||||
assert.Error(err, "expected findExternalAddress to fail on a node with missing ip information")
|
||||
}
|
||||
|
||||
type fakeEndpointReconciler struct{}
|
||||
|
||||
func (*fakeEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []api.EndpointPort, reconcilePorts bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TestNewBootstrapController verifies master fields are properly copied into controller
|
||||
func TestNewBootstrapController(t *testing.T) {
|
||||
// Tests a subset of inputs to ensure they are set properly in the controller
|
||||
@@ -254,14 +261,24 @@ func TestNewBootstrapController(t *testing.T) {
|
||||
master.ServiceReadWritePort = 1000
|
||||
master.PublicReadWritePort = 1010
|
||||
|
||||
controller := master.NewBootstrapController()
|
||||
// test with an empty EndpointReconcilerConfig to ensure the defaults are applied
|
||||
controller := master.NewBootstrapController(EndpointReconcilerConfig{})
|
||||
|
||||
assert.Equal(controller.NamespaceRegistry, master.namespaceRegistry)
|
||||
assert.Equal(controller.EndpointReconciler, NewMasterCountEndpointReconciler(master.MasterCount, master.endpointRegistry))
|
||||
assert.Equal(controller.EndpointInterval, DefaultEndpointReconcilerInterval)
|
||||
assert.Equal(controller.ServiceRegistry, master.serviceRegistry)
|
||||
assert.Equal(controller.ServiceNodePortRange, portRange)
|
||||
assert.Equal(controller.ServicePort, master.ServiceReadWritePort)
|
||||
assert.Equal(controller.PublicServicePort, master.PublicReadWritePort)
|
||||
|
||||
// test with a filled-in EndpointReconcilerConfig to make sure its values are used
|
||||
controller = master.NewBootstrapController(EndpointReconcilerConfig{
|
||||
Reconciler: &fakeEndpointReconciler{},
|
||||
Interval: 5 * time.Second,
|
||||
})
|
||||
assert.Equal(controller.EndpointReconciler, &fakeEndpointReconciler{})
|
||||
assert.Equal(controller.EndpointInterval, 5*time.Second)
|
||||
}
|
||||
|
||||
// TestControllerServicePorts verifies master extraServicePorts are
|
||||
@@ -289,7 +306,7 @@ func TestControllerServicePorts(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
controller := master.NewBootstrapController()
|
||||
controller := master.NewBootstrapController(EndpointReconcilerConfig{})
|
||||
|
||||
assert.Equal(int32(1000), controller.ExtraServicePorts[0].Port)
|
||||
assert.Equal(int32(1010), controller.ExtraServicePorts[1].Port)
|
||||
|
Reference in New Issue
Block a user