mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
add federation-name and zone-name as controller manager flags
This commit is contained in:
parent
29cc7c009c
commit
318f37ce0f
@ -121,7 +121,7 @@ func StartControllers(s *options.CMServer, restClientCfg *restclient.Config) err
|
|||||||
glog.Fatalf("Cloud provider could not be initialized: %v", err)
|
glog.Fatalf("Cloud provider could not be initialized: %v", err)
|
||||||
}
|
}
|
||||||
scClientset := federationclientset.NewForConfigOrDie(restclient.AddUserAgent(restClientCfg, servicecontroller.UserAgentName))
|
scClientset := federationclientset.NewForConfigOrDie(restclient.AddUserAgent(restClientCfg, servicecontroller.UserAgentName))
|
||||||
servicecontroller := servicecontroller.New(scClientset, dns)
|
servicecontroller := servicecontroller.New(scClientset, dns, s.FederationName, s.ZoneName)
|
||||||
if err := servicecontroller.Run(s.ConcurrentServiceSyncs, wait.NeverStop); err != nil {
|
if err := servicecontroller.Run(s.ConcurrentServiceSyncs, wait.NeverStop); err != nil {
|
||||||
glog.Errorf("Failed to start service controller: %v", err)
|
glog.Errorf("Failed to start service controller: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,10 @@ type ControllerManagerConfiguration struct {
|
|||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
// address is the IP address to serve on (set to 0.0.0.0 for all interfaces).
|
// address is the IP address to serve on (set to 0.0.0.0 for all interfaces).
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
|
// federation name.
|
||||||
|
FederationName string `json:"federationName"`
|
||||||
|
// zone name, like example.com.
|
||||||
|
ZoneName string `json:"zoneName"`
|
||||||
// dnsProvider is the provider for dns services.
|
// dnsProvider is the provider for dns services.
|
||||||
DnsProvider string `json:"dnsProvider"`
|
DnsProvider string `json:"dnsProvider"`
|
||||||
// dnsConfigFile is the path to the dns provider configuration file.
|
// dnsConfigFile is the path to the dns provider configuration file.
|
||||||
@ -90,6 +94,8 @@ func NewCMServer() *CMServer {
|
|||||||
func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
|
func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
|
||||||
fs.IntVar(&s.Port, "port", s.Port, "The port that the controller-manager's http service runs on")
|
fs.IntVar(&s.Port, "port", s.Port, "The port that the controller-manager's http service runs on")
|
||||||
fs.Var(componentconfig.IPVar{Val: &s.Address}, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
fs.Var(componentconfig.IPVar{Val: &s.Address}, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
||||||
|
fs.StringVar(&s.FederationName, "federation-name", s.FederationName, "Federation name.")
|
||||||
|
fs.StringVar(&s.ZoneName, "zone-name", s.ZoneName, "Zone name, like example.com.")
|
||||||
fs.IntVar(&s.ConcurrentServiceSyncs, "concurrent-service-syncs", s.ConcurrentServiceSyncs, "The number of service syncing operations that will be done concurrently. Larger number = faster endpoint updating, but more CPU (and network) load")
|
fs.IntVar(&s.ConcurrentServiceSyncs, "concurrent-service-syncs", s.ConcurrentServiceSyncs, "The number of service syncing operations that will be done concurrently. Larger number = faster endpoint updating, but more CPU (and network) load")
|
||||||
fs.DurationVar(&s.ClusterMonitorPeriod.Duration, "cluster-monitor-period", s.ClusterMonitorPeriod.Duration, "The period for syncing ClusterStatus in ClusterController.")
|
fs.DurationVar(&s.ClusterMonitorPeriod.Duration, "cluster-monitor-period", s.ClusterMonitorPeriod.Duration, "The period for syncing ClusterStatus in ClusterController.")
|
||||||
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
|
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
|
||||||
|
@ -58,7 +58,7 @@ func (rrsets ResourceRecordSets) Add(rrset dnsprovider.ResourceRecordSet) (dnspr
|
|||||||
|
|
||||||
func (rrsets ResourceRecordSets) Remove(rrset dnsprovider.ResourceRecordSet) error {
|
func (rrsets ResourceRecordSets) Remove(rrset dnsprovider.ResourceRecordSet) error {
|
||||||
service := rrsets.zone.zones.interface_.service.Changes()
|
service := rrsets.zone.zones.interface_.service.Changes()
|
||||||
deletions := []interfaces.ResourceRecordSet{rrset.(ResourceRecordSet).impl}
|
deletions := []interfaces.ResourceRecordSet{rrset.(*ResourceRecordSet).impl}
|
||||||
change := service.NewChange([]interfaces.ResourceRecordSet{}, deletions)
|
change := service.NewChange([]interfaces.ResourceRecordSet{}, deletions)
|
||||||
newChange, err := service.Create(rrsets.project(), rrsets.zone.impl.Name(), change).Do()
|
newChange, err := service.Create(rrsets.project(), rrsets.zone.impl.Name(), change).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -85,8 +85,7 @@ func (s *ServiceController) getClusterZoneNames(clusterName string) (zones []str
|
|||||||
|
|
||||||
// getFederationDNSZoneName returns the name of the managed DNS Zone configured for this federation
|
// getFederationDNSZoneName returns the name of the managed DNS Zone configured for this federation
|
||||||
func (s *ServiceController) getFederationDNSZoneName() (string, error) {
|
func (s *ServiceController) getFederationDNSZoneName() (string, error) {
|
||||||
return "example.com", nil // TODO: quinton: Get this from the federation configuration.
|
return s.zoneName, nil
|
||||||
// Note: For unit testing this must match the domain populated in the test/stub dnsprovider.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDnsZone is a hack around the fact that dnsprovider does not yet support a Get() method, only a List() method. TODO: Fix that.
|
// getDnsZone is a hack around the fact that dnsprovider does not yet support a Get() method, only a List() method. TODO: Fix that.
|
||||||
@ -254,12 +253,12 @@ func (s *ServiceController) ensureDnsRecords(clusterName string, cachedService *
|
|||||||
// the state of the service when we last successfully sync'd it's DNS records.
|
// the state of the service when we last successfully sync'd it's DNS records.
|
||||||
// So this time around we only need to patch that (add new records, remove deleted records, and update changed records.
|
// So this time around we only need to patch that (add new records, remove deleted records, and update changed records.
|
||||||
//
|
//
|
||||||
if s.dns == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return fmt.Errorf("nil ServiceController passed to ServiceController.ensureDnsRecords(clusterName: %s, cachedService: %v)", clusterName, cachedService)
|
return fmt.Errorf("nil ServiceController passed to ServiceController.ensureDnsRecords(clusterName: %s, cachedService: %v)", clusterName, cachedService)
|
||||||
}
|
}
|
||||||
|
if s.dns == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if cachedService == nil {
|
if cachedService == nil {
|
||||||
return fmt.Errorf("nil cachedService passed to ServiceController.ensureDnsRecords(clusterName: %s, cachedService: %v)", clusterName, cachedService)
|
return fmt.Errorf("nil cachedService passed to ServiceController.ensureDnsRecords(clusterName: %s, cachedService: %v)", clusterName, cachedService)
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ type ServiceController struct {
|
|||||||
dns dnsprovider.Interface
|
dns dnsprovider.Interface
|
||||||
federationClient federation_release_1_3.Interface
|
federationClient federation_release_1_3.Interface
|
||||||
federationName string
|
federationName string
|
||||||
|
zoneName string
|
||||||
// each federation should be configured with a single zone (e.g. "mycompany.com")
|
// each federation should be configured with a single zone (e.g. "mycompany.com")
|
||||||
dnsZones dnsprovider.Zones
|
dnsZones dnsprovider.Zones
|
||||||
serviceCache *serviceCache
|
serviceCache *serviceCache
|
||||||
@ -123,7 +124,7 @@ type ServiceController struct {
|
|||||||
// New returns a new service controller to keep DNS provider service resources
|
// New returns a new service controller to keep DNS provider service resources
|
||||||
// (like Kubernetes Services and DNS server records for service discovery) in sync with the registry.
|
// (like Kubernetes Services and DNS server records for service discovery) in sync with the registry.
|
||||||
|
|
||||||
func New(federationClient federation_release_1_3.Interface, dns dnsprovider.Interface) *ServiceController {
|
func New(federationClient federation_release_1_3.Interface, dns dnsprovider.Interface, federationName, zoneName string) *ServiceController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
// federationClient event is not supported yet
|
// federationClient event is not supported yet
|
||||||
// broadcaster.StartRecordingToSink(&unversioned_core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
|
// broadcaster.StartRecordingToSink(&unversioned_core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
|
||||||
@ -132,6 +133,8 @@ func New(federationClient federation_release_1_3.Interface, dns dnsprovider.Inte
|
|||||||
s := &ServiceController{
|
s := &ServiceController{
|
||||||
dns: dns,
|
dns: dns,
|
||||||
federationClient: federationClient,
|
federationClient: federationClient,
|
||||||
|
federationName: federationName,
|
||||||
|
zoneName: zoneName,
|
||||||
serviceCache: &serviceCache{fedServiceMap: make(map[string]*cachedService)},
|
serviceCache: &serviceCache{fedServiceMap: make(map[string]*cachedService)},
|
||||||
clusterCache: &clusterClientCache{
|
clusterCache: &clusterClientCache{
|
||||||
rwlock: sync.Mutex{},
|
rwlock: sync.Mutex{},
|
||||||
@ -246,6 +249,12 @@ func (s *ServiceController) Run(workers int, stopCh <-chan struct{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceController) init() error {
|
func (s *ServiceController) init() error {
|
||||||
|
if s.federationName == "" {
|
||||||
|
return fmt.Errorf("ServiceController should not be run without federationName.")
|
||||||
|
}
|
||||||
|
if s.zoneName == "" {
|
||||||
|
return fmt.Errorf("ServiceController should not be run without zoneName.")
|
||||||
|
}
|
||||||
if s.dns == nil {
|
if s.dns == nil {
|
||||||
return fmt.Errorf("ServiceController should not be run without a dnsprovider.")
|
return fmt.Errorf("ServiceController should not be run without a dnsprovider.")
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ fake-clientset
|
|||||||
federated-api-burst
|
federated-api-burst
|
||||||
federated-api-qps
|
federated-api-qps
|
||||||
federated-kube-context
|
federated-kube-context
|
||||||
|
federation-name
|
||||||
file-check-frequency
|
file-check-frequency
|
||||||
file-suffix
|
file-suffix
|
||||||
file_content_in_loop
|
file_content_in_loop
|
||||||
@ -473,3 +474,4 @@ watch-only
|
|||||||
whitelist-override-label
|
whitelist-override-label
|
||||||
windows-line-endings
|
windows-line-endings
|
||||||
www-prefix
|
www-prefix
|
||||||
|
zone-name
|
||||||
|
Loading…
Reference in New Issue
Block a user