예제 #1
0
func NewKubeDNSServerDefault(config *options.KubeDNSConfig) *KubeDNSServer {
	kubeClient, err := newKubeClient(config)
	if err != nil {
		glog.Fatalf("Failed to create a kubernetes client: %v", err)
	}

	var configSync dnsconfig.Sync
	if config.ConfigMap == "" {
		glog.V(0).Infof("ConfigMap not configured, using values from command line flags")
		configSync = dnsconfig.NewNopSync(
			&dnsconfig.Config{Federations: config.Federations})
	} else {
		glog.V(0).Infof("Using configuration read from ConfigMap: %v:%v",
			config.ConfigMapNs, config.ConfigMap)
		configSync = dnsconfig.NewSync(
			kubeClient, config.ConfigMapNs, config.ConfigMap)
	}

	return &KubeDNSServer{
		domain:         config.ClusterDomain,
		healthzPort:    config.HealthzPort,
		dnsBindAddress: config.DNSBindAddress,
		dnsPort:        config.DNSPort,
		kd:             kdns.NewKubeDNS(kubeClient, config.ClusterDomain, config.InitialSyncTimeout, configSync),
	}
}
예제 #2
0
func newKubeDNS() *KubeDNS {
	return &KubeDNS{
		domain:     testDomain,
		domainPath: util.ReverseArray(strings.Split(strings.TrimRight(testDomain, "."), ".")),

		endpointsStore: cache.NewStore(cache.MetaNamespaceKeyFunc),
		servicesStore:  cache.NewStore(cache.MetaNamespaceKeyFunc),
		nodesStore:     cache.NewStore(cache.MetaNamespaceKeyFunc),

		cache:               treecache.NewTreeCache(),
		reverseRecordMap:    make(map[string]*skymsg.Service),
		clusterIPServiceMap: make(map[string]*v1.Service),
		cacheLock:           sync.RWMutex{},

		config:     config.NewDefaultConfig(),
		configLock: sync.RWMutex{},
		configSync: config.NewNopSync(config.NewDefaultConfig()),
	}
}