func newKubernetesMaster(scheduler *scheduler.KubernetesScheduler, c *master.Config) *kubernetesMaster { var m *kubernetesMaster if len(c.EtcdServers) > 0 { etcdClient := etcd.NewClient(c.EtcdServers) minionRegistry := registry.MakeMinionRegistry(c.Minions) m = &kubernetesMaster{ podRegistry: scheduler, controllerRegistry: registry.MakeEtcdRegistry(etcdClient, minionRegistry), serviceRegistry: registry.MakeEtcdRegistry(etcdClient, minionRegistry), minionRegistry: minionRegistry, client: c.Client, } m.init(scheduler, c.Cloud, c.PodInfoGetter) } else { m = &kubernetesMaster{ podRegistry: scheduler, controllerRegistry: registry.MakeMemoryRegistry(), serviceRegistry: registry.MakeMemoryRegistry(), minionRegistry: registry.MakeMinionRegistry(c.Minions), client: c.Client, } m.init(scheduler, c.Cloud, c.PodInfoGetter) } return m }
// Returns a memory (not etcd) backed apiserver. func NewMemoryServer(minions []string, cloud cloudprovider.Interface) *Master { m := &Master{ podRegistry: registry.MakeMemoryRegistry(), controllerRegistry: registry.MakeMemoryRegistry(), serviceRegistry: registry.MakeMemoryRegistry(), } m.init(minions, cloud) return m }
// Returns a memory (not etcd) backed apiserver. func NewMemoryServer(minions []string, podInfoGetter client.PodInfoGetter, cloud cloudprovider.Interface) *Master { m := &Master{ podRegistry: registry.MakeMemoryRegistry(), controllerRegistry: registry.MakeMemoryRegistry(), serviceRegistry: registry.MakeMemoryRegistry(), minionRegistry: registry.MakeMinionRegistry(minions), } m.init(cloud, podInfoGetter) return m }
// NewMemoryServer returns a new instance of Master backed with memory (not etcd). func NewMemoryServer(c *Config) *Master { m := &Master{ podRegistry: registry.MakeMemoryRegistry(), controllerRegistry: registry.MakeMemoryRegistry(), serviceRegistry: registry.MakeMemoryRegistry(), minionRegistry: registry.MakeMinionRegistry(c.Minions), client: c.Client, } m.init(c.Cloud, c.PodInfoGetter) return m }
func main() { flag.Parse() if len(machineList) == 0 { log.Fatal("No machines specified!") } var ( podRegistry registry.PodRegistry controllerRegistry registry.ControllerRegistry serviceRegistry registry.ServiceRegistry ) if len(etcdServerList) > 0 { log.Printf("Creating etcd client pointing to %v", etcdServerList) etcdClient := etcd.NewClient(etcdServerList) podRegistry = registry.MakeEtcdRegistry(etcdClient, machineList) controllerRegistry = registry.MakeEtcdRegistry(etcdClient, machineList) serviceRegistry = registry.MakeEtcdRegistry(etcdClient, machineList) } else { podRegistry = registry.MakeMemoryRegistry() controllerRegistry = registry.MakeMemoryRegistry() serviceRegistry = registry.MakeMemoryRegistry() } containerInfo := &kube_client.HTTPContainerInfo{ Client: http.DefaultClient, Port: 10250, } random := rand.New(rand.NewSource(int64(time.Now().Nanosecond()))) storage := map[string]apiserver.RESTStorage{ "pods": registry.MakePodRegistryStorage(podRegistry, containerInfo, registry.MakeFirstFitScheduler(machineList, podRegistry, random)), "replicationControllers": registry.MakeControllerRegistryStorage(controllerRegistry), "services": registry.MakeServiceRegistryStorage(serviceRegistry), } endpoints := registry.MakeEndpointController(serviceRegistry, podRegistry) go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10) s := &http.Server{ Addr: fmt.Sprintf("%s:%d", *address, *port), Handler: apiserver.New(storage, *apiPrefix), ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } log.Fatal(s.ListenAndServe()) }