Пример #1
0
func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInfoGetter) {
	podCache := NewPodCache(podInfoGetter, m.podRegistry, time.Second*30)
	go podCache.Loop()

	endpoints := endpoint.NewEndpointController(m.serviceRegistry, m.client)
	go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)

	random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
	s := scheduler.NewRandomFitScheduler(m.podRegistry, random)
	m.storage = map[string]apiserver.RESTStorage{
		"pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{
			CloudProvider: cloud,
			MinionLister:  m.minionRegistry,
			PodCache:      podCache,
			PodInfoGetter: podInfoGetter,
			Registry:      m.podRegistry,
			Scheduler:     s,
		}),
		"replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry),
		"services":               service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
		"minions":                minion.NewRegistryStorage(m.minionRegistry),

		// TODO: should appear only in scheduler API group.
		"bindings": binding.NewBindingStorage(m.bindingRegistry),
	}
}
Пример #2
0
func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInfoGetter) {
	podCache := NewPodCache(podInfoGetter, m.podRegistry)
	go util.Forever(func() { podCache.UpdateAllContainers() }, time.Second*30)

	endpoints := endpoint.NewEndpointController(m.serviceRegistry, m.client)
	go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)

	m.storage = map[string]apiserver.RESTStorage{
		"pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{
			CloudProvider: cloud,
			PodCache:      podCache,
			PodInfoGetter: podInfoGetter,
			Registry:      m.podRegistry,
		}),
		"replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry),
		"services":               service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
		"minions":                minion.NewRegistryStorage(m.minionRegistry),

		// TODO: should appear only in scheduler API group.
		"bindings": binding.NewBindingStorage(m.bindingRegistry),
	}
}