// Run launches a template router using the provided options. It never exits. func (o *TemplateRouterOptions) Run() error { pluginCfg := templateplugin.TemplatePluginConfig{ WorkingDir: o.WorkingDir, TemplatePath: o.TemplateFile, ReloadScriptPath: o.ReloadScript, DefaultCertificate: o.DefaultCertificate, StatsPort: o.StatsPort, StatsUsername: o.StatsUsername, StatsPassword: o.StatsPassword, PeerService: o.RouterService, IncludeUDP: o.RouterSelection.IncludeUDP, } templatePlugin, err := templateplugin.NewTemplatePlugin(pluginCfg) if err != nil { return err } plugin := controller.NewUniqueHost(templatePlugin, controller.HostForRoute) oc, kc, err := o.Config.Clients() if err != nil { return err } factory := o.RouterSelection.NewFactory(oc, kc) controller := factory.Create(plugin) controller.Run() proc.StartReaper() select {} }
// Run launches an F5 route sync process using the provided options. It never exits. func (o *F5RouterOptions) Run() error { cfg := f5plugin.F5PluginConfig{ Host: o.Host, Username: o.Username, Password: o.Password, HttpVserver: o.HttpVserver, HttpsVserver: o.HttpsVserver, PrivateKey: o.PrivateKey, Insecure: o.Insecure, PartitionPath: o.PartitionPath, } f5Plugin, err := f5plugin.NewF5Plugin(cfg) if err != nil { return err } oc, kc, err := o.Config.Clients() if err != nil { return err } statusPlugin := controller.NewStatusAdmitter(f5Plugin, oc, o.RouterName) plugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), statusPlugin) factory := o.RouterSelection.NewFactory(oc, kc) controller := factory.Create(plugin) controller.Run() select {} }
// Run launches an F5 route sync process using the provided options. It never exits. func (o *F5RouterOptions) Run() error { cfg := f5plugin.F5PluginConfig{ Host: o.Host, Username: o.Username, Password: o.Password, HttpVserver: o.HttpVserver, HttpsVserver: o.HttpsVserver, PrivateKey: o.PrivateKey, Insecure: o.Insecure, } f5Plugin, err := f5plugin.NewF5Plugin(cfg) if err != nil { return err } plugin := controller.NewUniqueHost(f5Plugin, controller.HostForRoute) oc, kc, err := o.Config.Clients() if err != nil { return err } factory := o.RouterSelection.NewFactory(oc, kc) controller := factory.Create(plugin) controller.Run() select {} }
// Run launches an F5 route sync process using the provided options. It never exits. func (o *F5RouterOptions) Run() error { cfg := f5plugin.F5PluginConfig{ Host: o.Host, Username: o.Username, Password: o.Password, HttpVserver: o.HttpVserver, HttpsVserver: o.HttpsVserver, PrivateKey: o.PrivateKey, Insecure: o.Insecure, PartitionPath: o.PartitionPath, InternalAddress: o.InternalAddress, VxlanGateway: o.VxlanGateway, } f5Plugin, err := f5plugin.NewF5Plugin(cfg) if err != nil { return err } oc, _, kc, err := o.Config.Clients() if err != nil { return err } statusPlugin := controller.NewStatusAdmitter(f5Plugin, oc, o.RouterName) uniqueHostPlugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), statusPlugin) plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.F5RouteAdmitterFunc(), false, statusPlugin) factory := o.RouterSelection.NewFactory(oc, kc) watchNodes := (len(o.InternalAddress) != 0 && len(o.VxlanGateway) != 0) controller := factory.Create(plugin, watchNodes) controller.Run() select {} }
// launchRouter launches a template router that communicates with the // api via the provided clients. func launchRouter(oc osclient.Interface, kc kclient.Interface, maxDelay int32, name string, reloadInterval int, reloadCounts map[string]int) (templatePlugin *templateplugin.TemplatePlugin) { r := templateplugin.NewFakeTemplateRouter() reloadCounts[name] = 0 r.EnableRateLimiter(reloadInterval, func() error { reloadCounts[name]++ return nil }) templatePlugin = &templateplugin.TemplatePlugin{Router: r} statusPlugin := controller.NewStatusAdmitter(templatePlugin, oc, name) validationPlugin := controller.NewExtendedValidator(statusPlugin, controller.RejectionRecorder(statusPlugin)) uniquePlugin := controller.NewUniqueHost(validationPlugin, controller.HostForRoute, controller.RejectionRecorder(statusPlugin)) var plugin router.Plugin = uniquePlugin if maxDelay > 0 { plugin = NewDelayPlugin(plugin, maxDelay) } factory := controllerfactory.NewDefaultRouterControllerFactory(oc, kc) controller := factory.Create(plugin) controller.Run() return }
// Run launches a template router using the provided options. It never exits. func (o *TemplateRouterOptions) Run() error { pluginCfg := templateplugin.TemplatePluginConfig{ WorkingDir: o.WorkingDir, TemplatePath: o.TemplateFile, ReloadScriptPath: o.ReloadScript, ReloadInterval: o.ReloadInterval, DefaultCertificate: o.DefaultCertificate, DefaultCertificatePath: o.DefaultCertificatePath, DefaultCertificateDir: o.DefaultCertificateDir, StatsPort: o.StatsPort, StatsUsername: o.StatsUsername, StatsPassword: o.StatsPassword, PeerService: o.RouterService, BindPortsAfterSync: o.BindPortsAfterSync, IncludeUDP: o.RouterSelection.IncludeUDP, AllowWildcardRoutes: o.RouterSelection.AllowWildcardRoutes, } oc, kc, err := o.Config.Clients() if err != nil { return err } svcFetcher := templateplugin.NewListWatchServiceLookup(kc.Core(), 10*time.Minute) templatePlugin, err := templateplugin.NewTemplatePlugin(pluginCfg, svcFetcher) if err != nil { return err } statusPlugin := controller.NewStatusAdmitter(templatePlugin, oc, o.RouterName) var nextPlugin router.Plugin = statusPlugin if o.ExtendedValidation { nextPlugin = controller.NewExtendedValidator(nextPlugin, controller.RejectionRecorder(statusPlugin)) } uniqueHostPlugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), controller.RejectionRecorder(statusPlugin)) plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.RouteAdmissionFunc(), o.RestrictSubdomainOwnership, controller.RejectionRecorder(statusPlugin)) factory := o.RouterSelection.NewFactory(oc, kc) controller := factory.Create(plugin, false) controller.Run() proc.StartReaper() select {} }
// Run launches a template router using the provided options. It never exits. func (o *TemplateRouterOptions) Run() error { pluginCfg := templateplugin.TemplatePluginConfig{ WorkingDir: o.WorkingDir, TemplatePath: o.TemplateFile, ReloadScriptPath: o.ReloadScript, ReloadInterval: o.ReloadInterval, DefaultCertificate: o.DefaultCertificate, DefaultCertificatePath: o.DefaultCertificatePath, StatsPort: o.StatsPort, StatsUsername: o.StatsUsername, StatsPassword: o.StatsPassword, PeerService: o.RouterService, IncludeUDP: o.RouterSelection.IncludeUDP, } templatePlugin, err := templateplugin.NewTemplatePlugin(pluginCfg) if err != nil { return err } oc, kc, err := o.Config.Clients() if err != nil { return err } statusPlugin := controller.NewStatusAdmitter(templatePlugin, oc, o.RouterName) var nextPlugin router.Plugin = statusPlugin if o.ExtendedValidation { nextPlugin = controller.NewExtendedValidator(nextPlugin, controller.RejectionRecorder(statusPlugin)) } plugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), controller.RejectionRecorder(statusPlugin)) factory := o.RouterSelection.NewFactory(oc, kc) controller := factory.Create(plugin) controller.Run() proc.StartReaper() select {} }