-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
server.go
70 lines (60 loc) · 2.52 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package openshift_apiserver
import (
"github.com/golang/glog"
kerrors "k8s.io/apimachinery/pkg/api/errors"
utilwait "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/pkg/version"
"k8s.io/kubernetes/pkg/capabilities"
kubelettypes "k8s.io/kubernetes/pkg/kubelet/types"
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
"github.com/openshift/origin/pkg/cmd/server/apis/config/validation"
"github.com/openshift/origin/pkg/cmd/server/origin"
"github.com/openshift/origin/pkg/cmd/util/variable"
)
func RunOpenShiftAPIServer(masterConfig *configapi.MasterConfig) error {
// Allow privileged containers
capabilities.Initialize(capabilities.Capabilities{
AllowPrivileged: true,
PrivilegedSources: capabilities.PrivilegedSources{
HostNetworkSources: []string{kubelettypes.ApiserverSource, kubelettypes.FileSource},
HostPIDSources: []string{kubelettypes.ApiserverSource, kubelettypes.FileSource},
HostIPCSources: []string{kubelettypes.ApiserverSource, kubelettypes.FileSource},
},
})
validationResults := validation.ValidateMasterConfig(masterConfig, nil)
if len(validationResults.Warnings) != 0 {
for _, warning := range validationResults.Warnings {
glog.Warningf("%v", warning)
}
}
if len(validationResults.Errors) != 0 {
return kerrors.NewInvalid(configapi.Kind("MasterConfig"), "master-config.yaml", validationResults.Errors)
}
// informers are shared amongst all the various api components we build
// TODO the needs of the apiserver and the controllers are drifting. We should consider two different skins here
clientConfig, err := configapi.GetClientConfig(masterConfig.MasterClients.OpenShiftLoopbackKubeConfig, masterConfig.MasterClients.OpenShiftLoopbackClientConnectionOverrides)
if err != nil {
return err
}
informers, err := origin.NewInformers(clientConfig)
if err != nil {
return err
}
if err := informers.AddUserIndexes(); err != nil {
return err
}
openshiftConfig, err := origin.BuildMasterConfig(*masterConfig, informers)
if err != nil {
return err
}
glog.Infof("Starting master on %s (%s)", masterConfig.ServingInfo.BindAddress, version.Get().String())
glog.Infof("Public master address is %s", masterConfig.MasterPublicURL)
imageTemplate := variable.NewDefaultImageTemplate()
imageTemplate.Format = masterConfig.ImageConfig.Format
imageTemplate.Latest = masterConfig.ImageConfig.Latest
glog.Infof("Using images from %q", imageTemplate.ExpandOrDie("<component>"))
if err := openshiftConfig.RunOpenShift(utilwait.NeverStop); err != nil {
return err
}
return nil
}