2015-01-30 17:04:39 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors.
|
2015-01-30 17:04:39 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-02-07 22:13:22 +00:00
|
|
|
// Package app does all of the work necessary to create a Kubernetes
|
2015-01-30 17:04:39 +00:00
|
|
|
// APIServer by binding together the API, master and APIServer infrastructure.
|
|
|
|
// It can be configured and called directly or via the hyperkube framework.
|
2015-02-07 22:13:22 +00:00
|
|
|
package app
|
2015-01-30 17:04:39 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"net"
|
2016-10-17 19:16:58 +00:00
|
|
|
"net/http"
|
2015-12-05 02:01:29 +00:00
|
|
|
"net/url"
|
2015-01-30 17:04:39 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2016-06-08 13:04:38 +00:00
|
|
|
"time"
|
2015-01-30 17:04:39 +00:00
|
|
|
|
2015-12-25 00:08:15 +00:00
|
|
|
"github.com/golang/glog"
|
2016-08-26 03:01:50 +00:00
|
|
|
"github.com/pborman/uuid"
|
2015-12-25 00:08:15 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
|
|
|
|
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/admission"
|
|
|
|
"k8s.io/kubernetes/pkg/api"
|
2015-11-13 21:20:54 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
2016-02-15 14:00:40 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
2016-02-17 17:11:31 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apis/batch"
|
2015-12-08 14:21:04 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apiserver"
|
2015-12-24 21:05:04 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apiserver/authenticator"
|
2016-10-08 09:36:37 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apiserver/openapi"
|
2016-08-26 03:01:50 +00:00
|
|
|
authorizerunion "k8s.io/kubernetes/pkg/auth/authorizer/union"
|
|
|
|
"k8s.io/kubernetes/pkg/auth/user"
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/capabilities"
|
|
|
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
2016-09-14 18:35:38 +00:00
|
|
|
"k8s.io/kubernetes/pkg/controller/informers"
|
2015-12-24 21:54:40 +00:00
|
|
|
serviceaccountcontroller "k8s.io/kubernetes/pkg/controller/serviceaccount"
|
2016-10-08 09:36:37 +00:00
|
|
|
generatedopenapi "k8s.io/kubernetes/pkg/generated/openapi"
|
2015-11-16 21:46:00 +00:00
|
|
|
"k8s.io/kubernetes/pkg/genericapiserver"
|
2016-07-12 20:44:36 +00:00
|
|
|
"k8s.io/kubernetes/pkg/genericapiserver/authorizer"
|
2016-08-09 11:35:53 +00:00
|
|
|
genericvalidation "k8s.io/kubernetes/pkg/genericapiserver/validation"
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/master"
|
2016-02-05 07:47:27 +00:00
|
|
|
"k8s.io/kubernetes/pkg/registry/cachesize"
|
2015-12-24 21:54:40 +00:00
|
|
|
"k8s.io/kubernetes/pkg/serviceaccount"
|
2016-10-17 19:16:58 +00:00
|
|
|
utilnet "k8s.io/kubernetes/pkg/util/net"
|
2016-06-30 08:50:41 +00:00
|
|
|
"k8s.io/kubernetes/pkg/util/wait"
|
2016-10-17 18:51:59 +00:00
|
|
|
"k8s.io/kubernetes/pkg/version"
|
2016-08-26 03:01:50 +00:00
|
|
|
authenticatorunion "k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/union"
|
2015-05-12 02:41:13 +00:00
|
|
|
)
|
|
|
|
|
2015-10-12 14:33:39 +00:00
|
|
|
// NewAPIServerCommand creates a *cobra.Command object with default parameters
|
|
|
|
func NewAPIServerCommand() *cobra.Command {
|
2015-12-25 00:08:15 +00:00
|
|
|
s := options.NewAPIServer()
|
2015-10-12 14:33:39 +00:00
|
|
|
s.AddFlags(pflag.CommandLine)
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "kube-apiserver",
|
|
|
|
Long: `The Kubernetes API server validates and configures data
|
|
|
|
for the api objects which include pods, services, replicationcontrollers, and
|
|
|
|
others. The API Server services REST operations and provides the frontend to the
|
|
|
|
cluster's shared state through which all other components interact.`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2015-01-30 17:04:39 +00:00
|
|
|
// Run runs the specified APIServer. This should never exit.
|
2015-12-25 00:08:15 +00:00
|
|
|
func Run(s *options.APIServer) error {
|
2016-08-09 11:35:53 +00:00
|
|
|
genericvalidation.VerifyEtcdServersList(s.ServerRunOptions)
|
2016-04-15 01:01:31 +00:00
|
|
|
genericapiserver.DefaultAndValidateRunOptions(s.ServerRunOptions)
|
2016-10-11 18:09:34 +00:00
|
|
|
genericConfig := genericapiserver.NewConfig(). // create the new config
|
|
|
|
ApplyOptions(s.ServerRunOptions). // apply the options selected
|
|
|
|
Complete() // set default values based on the known values
|
|
|
|
|
|
|
|
if err := genericConfig.MaybeGenerateServingCerts(); err != nil {
|
|
|
|
glog.Fatalf("Failed to generate service certificate: %v", err)
|
|
|
|
}
|
2015-05-22 06:12:57 +00:00
|
|
|
|
2015-01-30 17:04:39 +00:00
|
|
|
capabilities.Initialize(capabilities.Capabilities{
|
|
|
|
AllowPrivileged: s.AllowPrivileged,
|
2015-03-24 23:09:16 +00:00
|
|
|
// TODO(vmarmol): Implement support for HostNetworkSources.
|
2015-08-24 17:41:51 +00:00
|
|
|
PrivilegedSources: capabilities.PrivilegedSources{
|
|
|
|
HostNetworkSources: []string{},
|
2015-09-15 16:43:59 +00:00
|
|
|
HostPIDSources: []string{},
|
2015-08-10 08:14:01 +00:00
|
|
|
HostIPCSources: []string{},
|
2015-08-24 17:41:51 +00:00
|
|
|
},
|
2015-07-29 05:00:15 +00:00
|
|
|
PerConnectionBandwidthLimitBytesPerSec: s.MaxConnectionBytesPerSec,
|
2015-01-30 17:04:39 +00:00
|
|
|
})
|
|
|
|
|
2015-10-09 05:18:16 +00:00
|
|
|
// Setup tunneler if needed
|
2016-04-22 00:48:35 +00:00
|
|
|
var tunneler genericapiserver.Tunneler
|
2015-10-09 05:18:16 +00:00
|
|
|
var proxyDialerFn apiserver.ProxyDialerFunc
|
|
|
|
if len(s.SSHUser) > 0 {
|
|
|
|
// Get ssh key distribution func, if supported
|
2016-04-22 00:48:35 +00:00
|
|
|
var installSSH genericapiserver.InstallSSHKey
|
2016-04-27 21:25:59 +00:00
|
|
|
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
|
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Cloud provider could not be initialized: %v", err)
|
|
|
|
}
|
2015-10-09 05:18:16 +00:00
|
|
|
if cloud != nil {
|
|
|
|
if instances, supported := cloud.Instances(); supported {
|
|
|
|
installSSH = instances.AddSSHKeyToAllInstances
|
|
|
|
}
|
|
|
|
}
|
2015-12-05 02:01:29 +00:00
|
|
|
if s.KubeletConfig.Port == 0 {
|
|
|
|
glog.Fatalf("Must enable kubelet port if proxy ssh-tunneling is specified.")
|
|
|
|
}
|
2015-10-09 05:18:16 +00:00
|
|
|
// Set up the tunneler
|
2015-12-05 02:01:29 +00:00
|
|
|
// TODO(cjcullen): If we want this to handle per-kubelet ports or other
|
|
|
|
// kubelet listen-addresses, we need to plumb through options.
|
|
|
|
healthCheckPath := &url.URL{
|
|
|
|
Scheme: "https",
|
|
|
|
Host: net.JoinHostPort("127.0.0.1", strconv.FormatUint(uint64(s.KubeletConfig.Port), 10)),
|
|
|
|
Path: "healthz",
|
|
|
|
}
|
2016-04-22 00:48:35 +00:00
|
|
|
tunneler = genericapiserver.NewSSHTunneler(s.SSHUser, s.SSHKeyfile, healthCheckPath, installSSH)
|
2015-10-09 05:18:16 +00:00
|
|
|
|
|
|
|
// Use the tunneler's dialer to connect to the kubelet
|
|
|
|
s.KubeletConfig.Dial = tunneler.Dial
|
|
|
|
// Use the tunneler's dialer when proxying to pods, services, and nodes
|
|
|
|
proxyDialerFn = tunneler.Dial
|
|
|
|
}
|
|
|
|
|
|
|
|
// Proxying to pods and services is IP-based... don't expect to be able to verify the hostname
|
|
|
|
proxyTLSClientConfig := &tls.Config{InsecureSkipVerify: true}
|
|
|
|
|
2016-10-04 07:17:44 +00:00
|
|
|
if s.StorageConfig.DeserializationCacheSize == 0 {
|
|
|
|
// When size of cache is not explicitly set, estimate its size based on
|
|
|
|
// target memory usage.
|
|
|
|
glog.V(2).Infof("Initalizing deserialization cache size based on %dMB limit", s.TargetRAMMB)
|
|
|
|
|
|
|
|
// This is the heuristics that from memory capacity is trying to infer
|
|
|
|
// the maximum number of nodes in the cluster and set cache sizes based
|
|
|
|
// on that value.
|
|
|
|
// From our documentation, we officially recomment 120GB machines for
|
|
|
|
// 2000 nodes, and we scale from that point. Thus we assume ~60MB of
|
|
|
|
// capacity per node.
|
|
|
|
// TODO: We may consider deciding that some percentage of memory will
|
|
|
|
// be used for the deserialization cache and divide it by the max object
|
|
|
|
// size to compute its size. We may even go further and measure
|
|
|
|
// collective sizes of the objects in the cache.
|
|
|
|
clusterSize := s.TargetRAMMB / 60
|
|
|
|
s.StorageConfig.DeserializationCacheSize = 25 * clusterSize
|
|
|
|
if s.StorageConfig.DeserializationCacheSize < 1000 {
|
|
|
|
s.StorageConfig.DeserializationCacheSize = 1000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-26 07:43:56 +00:00
|
|
|
storageGroupsToEncodingVersion, err := s.StorageGroupsToEncodingVersion()
|
2015-10-13 00:40:37 +00:00
|
|
|
if err != nil {
|
2016-04-26 07:43:56 +00:00
|
|
|
glog.Fatalf("error generating storage version map: %s", err)
|
2015-05-11 23:09:25 +00:00
|
|
|
}
|
2016-04-26 07:43:56 +00:00
|
|
|
storageFactory, err := genericapiserver.BuildDefaultStorageFactory(
|
|
|
|
s.StorageConfig, s.DefaultStorageMediaType, api.Codecs,
|
|
|
|
genericapiserver.NewDefaultResourceEncodingConfig(), storageGroupsToEncodingVersion,
|
2016-05-23 10:39:40 +00:00
|
|
|
// FIXME: this GroupVersionResource override should be configurable
|
|
|
|
[]unversioned.GroupVersionResource{batch.Resource("scheduledjobs").WithVersion("v2alpha1")},
|
2016-04-26 07:43:56 +00:00
|
|
|
master.DefaultAPIResourceConfigSource(), s.RuntimeConfig)
|
2015-01-30 17:04:39 +00:00
|
|
|
if err != nil {
|
2016-04-26 07:43:56 +00:00
|
|
|
glog.Fatalf("error in initializing storage factory: %s", err)
|
2015-01-30 17:04:39 +00:00
|
|
|
}
|
2016-03-16 14:17:04 +00:00
|
|
|
storageFactory.AddCohabitatingResources(batch.Resource("jobs"), extensions.Resource("jobs"))
|
|
|
|
storageFactory.AddCohabitatingResources(autoscaling.Resource("horizontalpodautoscalers"), extensions.Resource("horizontalpodautoscalers"))
|
|
|
|
for _, override := range s.EtcdServersOverrides {
|
|
|
|
tokens := strings.Split(override, "#")
|
|
|
|
if len(tokens) != 2 {
|
|
|
|
glog.Errorf("invalid value of etcd server overrides: %s", override)
|
|
|
|
continue
|
2016-02-17 17:11:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-16 14:17:04 +00:00
|
|
|
apiresource := strings.Split(tokens[0], "/")
|
|
|
|
if len(apiresource) != 2 {
|
|
|
|
glog.Errorf("invalid resource definition: %s", tokens[0])
|
|
|
|
continue
|
2016-04-15 22:30:15 +00:00
|
|
|
}
|
2016-03-16 14:17:04 +00:00
|
|
|
group := apiresource[0]
|
|
|
|
resource := apiresource[1]
|
|
|
|
groupResource := unversioned.GroupResource{Group: group, Resource: resource}
|
2016-04-15 22:30:15 +00:00
|
|
|
|
2016-03-16 14:17:04 +00:00
|
|
|
servers := strings.Split(tokens[1], ";")
|
|
|
|
storageFactory.SetEtcdLocation(groupResource, servers)
|
2016-04-15 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
2015-05-01 16:02:38 +00:00
|
|
|
// Default to the private server key for service account token signing
|
2016-10-04 17:31:17 +00:00
|
|
|
if len(s.ServiceAccountKeyFiles) == 0 && s.TLSPrivateKeyFile != "" {
|
2015-12-24 21:05:04 +00:00
|
|
|
if authenticator.IsValidServiceAccountKeyFile(s.TLSPrivateKeyFile) {
|
2016-10-04 17:31:17 +00:00
|
|
|
s.ServiceAccountKeyFiles = []string{s.TLSPrivateKeyFile}
|
2015-06-17 03:02:54 +00:00
|
|
|
} else {
|
2016-10-04 17:31:17 +00:00
|
|
|
glog.Warning("No TLS key provided, service account token authentication disabled")
|
2015-06-17 03:02:54 +00:00
|
|
|
}
|
2015-05-01 16:02:38 +00:00
|
|
|
}
|
2015-12-24 21:54:40 +00:00
|
|
|
|
|
|
|
var serviceAccountGetter serviceaccount.ServiceAccountTokenGetter
|
|
|
|
if s.ServiceAccountLookup {
|
|
|
|
// If we need to look up service accounts and tokens,
|
|
|
|
// go directly to etcd to avoid recursive auth insanity
|
2016-08-08 22:12:54 +00:00
|
|
|
storageConfig, err := storageFactory.NewConfig(api.Resource("serviceaccounts"))
|
2016-03-16 14:17:04 +00:00
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Unable to get serviceaccounts storage: %v", err)
|
|
|
|
}
|
2016-08-08 22:12:54 +00:00
|
|
|
serviceAccountGetter = serviceaccountcontroller.NewGetterFromStorageInterface(storageConfig, storageFactory.ResourcePrefix(api.Resource("serviceaccounts")), storageFactory.ResourcePrefix(api.Resource("secrets")))
|
2015-12-24 21:54:40 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 03:01:50 +00:00
|
|
|
apiAuthenticator, err := authenticator.New(authenticator.AuthenticatorConfig{
|
2016-09-09 14:18:08 +00:00
|
|
|
Anonymous: s.AnonymousAuth,
|
2016-09-23 16:35:31 +00:00
|
|
|
AnyToken: s.EnableAnyToken,
|
2016-04-28 01:08:33 +00:00
|
|
|
BasicAuthFile: s.BasicAuthFile,
|
|
|
|
ClientCAFile: s.ClientCAFile,
|
|
|
|
TokenAuthFile: s.TokenAuthFile,
|
|
|
|
OIDCIssuerURL: s.OIDCIssuerURL,
|
|
|
|
OIDCClientID: s.OIDCClientID,
|
|
|
|
OIDCCAFile: s.OIDCCAFile,
|
|
|
|
OIDCUsernameClaim: s.OIDCUsernameClaim,
|
|
|
|
OIDCGroupsClaim: s.OIDCGroupsClaim,
|
2016-10-04 17:31:17 +00:00
|
|
|
ServiceAccountKeyFiles: s.ServiceAccountKeyFiles,
|
2016-04-28 01:08:33 +00:00
|
|
|
ServiceAccountLookup: s.ServiceAccountLookup,
|
|
|
|
ServiceAccountTokenGetter: serviceAccountGetter,
|
|
|
|
KeystoneURL: s.KeystoneURL,
|
|
|
|
WebhookTokenAuthnConfigFile: s.WebhookTokenAuthnConfigFile,
|
2016-05-14 23:35:11 +00:00
|
|
|
WebhookTokenAuthnCacheTTL: s.WebhookTokenAuthnCacheTTL,
|
2015-08-19 00:36:22 +00:00
|
|
|
})
|
|
|
|
|
2015-01-30 17:04:39 +00:00
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Invalid Authentication Config: %v", err)
|
|
|
|
}
|
|
|
|
|
2016-10-04 20:02:56 +00:00
|
|
|
privilegedLoopbackToken := uuid.NewRandom().String()
|
|
|
|
selfClientConfig, err := s.NewSelfClientConfig(privilegedLoopbackToken)
|
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Failed to create clientset: %v", err)
|
2016-05-25 21:20:41 +00:00
|
|
|
}
|
2016-10-04 20:02:56 +00:00
|
|
|
client, err := s.NewSelfClient(privilegedLoopbackToken)
|
|
|
|
if err != nil {
|
|
|
|
glog.Errorf("Failed to create clientset: %v", err)
|
|
|
|
}
|
|
|
|
sharedInformers := informers.NewSharedInformerFactory(client, 10*time.Minute)
|
2016-05-25 21:20:41 +00:00
|
|
|
|
2016-07-12 20:44:36 +00:00
|
|
|
authorizationConfig := authorizer.AuthorizationConfig{
|
|
|
|
PolicyFile: s.AuthorizationPolicyFile,
|
|
|
|
WebhookConfigFile: s.AuthorizationWebhookConfigFile,
|
|
|
|
WebhookCacheAuthorizedTTL: s.AuthorizationWebhookCacheAuthorizedTTL,
|
|
|
|
WebhookCacheUnauthorizedTTL: s.AuthorizationWebhookCacheUnauthorizedTTL,
|
|
|
|
RBACSuperUser: s.AuthorizationRBACSuperUser,
|
2016-10-04 20:02:56 +00:00
|
|
|
InformerFactory: sharedInformers,
|
2016-07-12 20:44:36 +00:00
|
|
|
}
|
2016-10-04 20:02:56 +00:00
|
|
|
authorizationModeNames := strings.Split(s.AuthorizationMode, ",")
|
2016-08-26 03:01:50 +00:00
|
|
|
apiAuthorizer, err := authorizer.NewAuthorizerFromAuthorizationConfig(authorizationModeNames, authorizationConfig)
|
2015-01-30 17:04:39 +00:00
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Invalid Authorization Config: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
admissionControlPluginNames := strings.Split(s.AdmissionControl, ",")
|
2016-08-26 03:01:50 +00:00
|
|
|
|
|
|
|
// TODO(dims): We probably need to add an option "EnableLoopbackToken"
|
|
|
|
if apiAuthenticator != nil {
|
|
|
|
var uid = uuid.NewRandom().String()
|
|
|
|
tokens := make(map[string]*user.DefaultInfo)
|
|
|
|
tokens[privilegedLoopbackToken] = &user.DefaultInfo{
|
2016-09-29 20:27:14 +00:00
|
|
|
Name: user.APIServerUser,
|
2016-08-26 03:01:50 +00:00
|
|
|
UID: uid,
|
2016-09-29 20:27:14 +00:00
|
|
|
Groups: []string{user.SystemPrivilegedGroup},
|
2016-08-26 03:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tokenAuthenticator := authenticator.NewAuthenticatorFromTokens(tokens)
|
2016-09-22 19:03:34 +00:00
|
|
|
apiAuthenticator = authenticatorunion.New(tokenAuthenticator, apiAuthenticator)
|
2016-08-26 03:01:50 +00:00
|
|
|
|
2016-09-29 20:27:14 +00:00
|
|
|
tokenAuthorizer := authorizer.NewPrivilegedGroups(user.SystemPrivilegedGroup)
|
2016-09-22 19:03:34 +00:00
|
|
|
apiAuthorizer = authorizerunion.New(tokenAuthorizer, apiAuthorizer)
|
2016-08-26 03:01:50 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:14:44 +00:00
|
|
|
pluginInitializer := admission.NewPluginInitializer(sharedInformers, apiAuthorizer)
|
2016-06-08 13:04:38 +00:00
|
|
|
|
2016-06-30 08:50:41 +00:00
|
|
|
admissionController, err := admission.NewFromPlugins(client, admissionControlPluginNames, s.AdmissionControlConfigFile, pluginInitializer)
|
2016-06-08 13:20:37 +00:00
|
|
|
if err != nil {
|
2016-06-30 08:50:41 +00:00
|
|
|
glog.Fatalf("Failed to initialize plugins: %v", err)
|
2016-06-08 13:20:37 +00:00
|
|
|
}
|
2015-01-30 17:04:39 +00:00
|
|
|
|
2016-10-17 19:16:58 +00:00
|
|
|
proxyTransport := utilnet.SetTransportDefaults(&http.Transport{
|
|
|
|
Dial: proxyDialerFn,
|
|
|
|
TLSClientConfig: proxyTLSClientConfig,
|
|
|
|
})
|
2016-10-17 18:51:59 +00:00
|
|
|
kubeVersion := version.Get()
|
2016-10-17 19:16:58 +00:00
|
|
|
|
2016-10-17 18:51:59 +00:00
|
|
|
genericConfig.Version = &kubeVersion
|
2016-09-29 19:10:04 +00:00
|
|
|
genericConfig.LoopbackClientConfig = selfClientConfig
|
2016-08-26 03:01:50 +00:00
|
|
|
genericConfig.Authenticator = apiAuthenticator
|
2016-04-15 01:01:31 +00:00
|
|
|
genericConfig.SupportsBasicAuth = len(s.BasicAuthFile) > 0
|
2016-08-26 03:01:50 +00:00
|
|
|
genericConfig.Authorizer = apiAuthorizer
|
2016-07-12 20:44:36 +00:00
|
|
|
genericConfig.AuthorizerRBACSuperUser = s.AuthorizationRBACSuperUser
|
2016-04-15 01:01:31 +00:00
|
|
|
genericConfig.AdmissionControl = admissionController
|
2016-04-26 07:43:56 +00:00
|
|
|
genericConfig.APIResourceConfigSource = storageFactory.APIResourceConfigSource
|
2016-04-15 01:01:31 +00:00
|
|
|
genericConfig.MasterServiceNamespace = s.MasterServiceNamespace
|
2016-10-08 09:36:37 +00:00
|
|
|
genericConfig.OpenAPIConfig.Info.Title = "Kubernetes"
|
|
|
|
genericConfig.OpenAPIConfig.Definitions = generatedopenapi.OpenAPIDefinitions
|
|
|
|
genericConfig.OpenAPIConfig.GetOperationID = openapi.GetOperationID
|
2016-09-14 00:11:36 +00:00
|
|
|
genericConfig.EnableOpenAPISupport = true
|
2016-04-15 01:01:31 +00:00
|
|
|
|
2015-01-30 17:04:39 +00:00
|
|
|
config := &master.Config{
|
2016-10-11 18:09:34 +00:00
|
|
|
GenericConfig: genericConfig.Config,
|
2016-09-19 18:52:41 +00:00
|
|
|
|
|
|
|
StorageFactory: storageFactory,
|
|
|
|
EnableWatchCache: s.EnableWatchCache,
|
2016-02-18 13:50:43 +00:00
|
|
|
EnableCoreControllers: true,
|
|
|
|
DeleteCollectionWorkers: s.DeleteCollectionWorkers,
|
|
|
|
EventTTL: s.EventTTL,
|
2016-10-07 19:30:45 +00:00
|
|
|
KubeletClientConfig: s.KubeletConfig,
|
2016-09-06 11:20:36 +00:00
|
|
|
EnableUISupport: true,
|
|
|
|
EnableLogsSupport: true,
|
2016-10-17 19:16:58 +00:00
|
|
|
ProxyTransport: proxyTransport,
|
2015-11-16 21:46:00 +00:00
|
|
|
|
|
|
|
Tunneler: tunneler,
|
2015-01-30 17:04:39 +00:00
|
|
|
}
|
2016-02-05 07:47:27 +00:00
|
|
|
|
|
|
|
if s.EnableWatchCache {
|
2016-08-03 09:44:10 +00:00
|
|
|
glog.V(2).Infof("Initalizing cache sizes based on %dMB limit", s.TargetRAMMB)
|
|
|
|
cachesize.InitializeWatchCacheSizes(s.TargetRAMMB)
|
2016-02-05 07:47:27 +00:00
|
|
|
cachesize.SetWatchCacheSizes(s.WatchCacheSizes)
|
|
|
|
}
|
|
|
|
|
2016-09-27 15:52:31 +00:00
|
|
|
m, err := config.Complete().New()
|
2016-02-03 22:26:11 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-02-05 07:47:27 +00:00
|
|
|
|
2016-06-30 08:50:41 +00:00
|
|
|
sharedInformers.Start(wait.NeverStop)
|
2016-09-30 16:16:32 +00:00
|
|
|
m.GenericAPIServer.Run()
|
2015-01-30 17:04:39 +00:00
|
|
|
return nil
|
|
|
|
}
|