Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/cmd/server/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ type MasterConfig struct {
// ProjectConfig holds information about project creation and defaults
ProjectConfig ProjectConfig

// RoutingConfig holds information about routing and route generation
RoutingConfig RoutingConfig

// NetworkConfig to be passed to the compiled in network plugin
NetworkConfig NetworkConfig
}
Expand All @@ -164,6 +167,11 @@ type ProjectConfig struct {
SecurityAllocator *SecurityAllocator
}

type RoutingConfig struct {
// Subdomain is the suffix appended to $service.$namespace. to form the default route hostname
Subdomain string
}

type SecurityAllocator struct {
// UIDAllocatorRange defines the total set of Unix user IDs (UIDs) that will be allocated to projects automatically, and the size of the
// block each namespace gets. For example, 1000-1999/10 will allocate ten UIDs per namespace, and will be able to allocate up to 100 blocks
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/server/api/v1/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func init() {
if len(obj.PolicyConfig.OpenShiftInfrastructureNamespace) == 0 {
obj.PolicyConfig.OpenShiftInfrastructureNamespace = bootstrappolicy.DefaultOpenShiftInfraNamespace
}
if len(obj.RoutingConfig.Subdomain) == 0 {
obj.RoutingConfig.Subdomain = "router.default.local"
}
},
func(obj *KubernetesMasterConfig) {
if obj.MasterCount == 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/server/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ type MasterConfig struct {
// ProjectConfig holds information about project creation and defaults
ProjectConfig ProjectConfig `json:"projectConfig"`

// RoutingConfig holds information about routing and route generation
RoutingConfig RoutingConfig `json:"routingConfig"`

// NetworkConfig to be passed to the compiled in network plugin
NetworkConfig NetworkConfig `json:"networkConfig"`
}
Expand Down Expand Up @@ -186,6 +189,11 @@ type PolicyConfig struct {
OpenShiftInfrastructureNamespace string `json:"openshiftInfrastructureNamespace"`
}

type RoutingConfig struct {
// Subdomain is the suffix appended to $service.$namespace. to form the default route hostname
Subdomain string `json:"subdomain"`
}

// NetworkConfig to be passed to the compiled in network plugin
type NetworkConfig struct {
NetworkPluginName string `json:"networkPluginName"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/server/api/v1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ projectConfig:
projectRequestMessage: ""
projectRequestTemplate: ""
securityAllocator: null
routingConfig:
subdomain: ""
serviceAccountConfig:
managedNames: null
privateKeyFile: ""
Expand Down
14 changes: 14 additions & 0 deletions pkg/cmd/server/api/validation/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func ValidateMasterConfig(config *api.MasterConfig) ValidationResults {

validationResults.AddErrors(ValidateProjectConfig(config.ProjectConfig).Prefix("projectConfig")...)

validationResults.AddErrors(ValidateRoutingConfig(config.RoutingConfig).Prefix("routingConfig")...)

validationResults.Append(ValidateAPILevels(config.APILevels, api.KnownOpenShiftAPILevels, api.DeadOpenShiftAPILevels, "apiLevels"))

return validationResults
Expand Down Expand Up @@ -361,3 +363,15 @@ func ValidateProjectConfig(config api.ProjectConfig) fielderrors.ValidationError
}
return allErrs
}

func ValidateRoutingConfig(config api.RoutingConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}

if len(config.Subdomain) == 0 {
allErrs = append(allErrs, fielderrors.NewFieldRequired("subdomain"))
} else if !util.IsDNS1123Subdomain(config.Subdomain) {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("subdomain", config.Subdomain, "must be a valid subdomain"))
}

return allErrs
}
5 changes: 1 addition & 4 deletions pkg/cmd/server/origin/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const (
OpenShiftAPIV1 = "v1"
OpenShiftAPIPrefixV1Beta3 = LegacyOpenShiftAPIPrefix + "/" + OpenShiftAPIV1Beta3
OpenShiftAPIPrefixV1 = OpenShiftAPIPrefix + "/" + OpenShiftAPIV1
OpenShiftRouteSubdomain = "router.default.local"
swaggerAPIPrefix = "/swaggerapi/"
)

Expand Down Expand Up @@ -1108,9 +1107,7 @@ func (c *MasterConfig) RouteAllocator() *routeallocationcontroller.RouteAllocati
KubeClient: kclient,
}

subdomain := env("OPENSHIFT_ROUTE_SUBDOMAIN", OpenShiftRouteSubdomain)

plugin, err := routeplugin.NewSimpleAllocationPlugin(subdomain)
plugin, err := routeplugin.NewSimpleAllocationPlugin(c.Options.RoutingConfig.Subdomain)
if err != nil {
glog.Fatalf("Route plugin initialization failed: %v", err)
}
Expand Down