// checkForOverrideConfig looks for ClusterResourceOverrideConfig plugin cfg in the admission PluginConfig func checkForOverrideConfig(ac configapi.AdmissionConfig) (*overrideapi.ClusterResourceOverrideConfig, error) { overridePluginConfigFile, err := pluginconfig.GetPluginConfigFile(ac.PluginConfig, overrideapi.PluginName, "") if err != nil { return nil, err } if overridePluginConfigFile == "" { return nil, nil } configFile, err := os.Open(overridePluginConfigFile) if err != nil { return nil, err } overrideConfig, err := override.ReadConfig(configFile) if err != nil { return nil, err } return overrideConfig, nil }
// StartAPI starts the components of the master that are considered part of the API - the Kubernetes // API and core controllers, the Origin API, the group, policy, project, and authorization caches, // etcd, the asset server (for the UI), the OAuth server endpoints, and the DNS server. // TODO: allow to be more granularly targeted func StartAPI(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) error { // start etcd if oc.Options.EtcdConfig != nil { etcdserver.RunEtcd(oc.Options.EtcdConfig) } // verify we can connect to etcd with the provided config if etcdClient, err := etcd.GetAndTestEtcdClient(oc.Options.EtcdClientInfo); err != nil { return err } else { etcdClient.Close() } // Must start policy caching immediately oc.RunGroupCache() oc.RunPolicyCache() oc.RunProjectCache() unprotectedInstallers := []origin.APIInstaller{} if oc.Options.OAuthConfig != nil { authConfig, err := origin.BuildAuthConfig(oc) if err != nil { return err } unprotectedInstallers = append(unprotectedInstallers, authConfig) } var standaloneAssetConfig *origin.AssetConfig if oc.WebConsoleEnabled() { var overrideConfig *overrideapi.ClusterResourceOverrideConfig = nil if oc.Options.KubernetesMasterConfig != nil { // external kube gets you a nil pointer here if overridePluginConfigFile, err := pluginconfig.GetPluginConfigFile(oc.Options.KubernetesMasterConfig.AdmissionConfig.PluginConfig, overrideapi.PluginName, ""); err != nil { return err } else if overridePluginConfigFile != "" { configFile, err := os.Open(overridePluginConfigFile) if err != nil { return err } if overrideConfig, err = override.ReadConfig(configFile); err != nil { return err } } } config, err := origin.NewAssetConfig(*oc.Options.AssetConfig, overrideConfig) if err != nil { return err } if oc.Options.AssetConfig.ServingInfo.BindAddress == oc.Options.ServingInfo.BindAddress { unprotectedInstallers = append(unprotectedInstallers, config) } else { standaloneAssetConfig = config } } if kc != nil { oc.Run([]origin.APIInstaller{kc}, unprotectedInstallers) } else { _, kubeClientConfig, err := configapi.GetKubeClient(oc.Options.MasterClients.ExternalKubernetesKubeConfig) if err != nil { return err } proxy := &kubernetes.ProxyConfig{ ClientConfig: kubeClientConfig, } oc.Run([]origin.APIInstaller{proxy}, unprotectedInstallers) } oc.InitializeObjects() if standaloneAssetConfig != nil { standaloneAssetConfig.Run() } if oc.Options.DNSConfig != nil { oc.RunDNSServer() } oc.RunProjectAuthorizationCache() return nil }