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
16 changes: 14 additions & 2 deletions pkg/cmd/server/kube_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
kmaster "github.com/GoogleCloudPlatform/kubernetes/pkg/master"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"

"github.com/openshift/origin/pkg/cmd/server/kubernetes"

// Admission control plugins from upstream Kubernetes
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/limitranger"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/namespace/exists"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/resourcedefaults"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/resourcequota"
)

func (cfg Config) BuildKubernetesMasterConfig(requestContextMapper kapi.RequestContextMapper, kubeClient *kclient.Client) (*kubernetes.MasterConfig, error) {
Expand Down Expand Up @@ -44,6 +51,11 @@ func (cfg Config) BuildKubernetesMasterConfig(requestContextMapper kapi.RequestC
masterIP = addrs[0]
}

// in-order list of plug-ins that should intercept admission decisions
// TODO: add NamespaceExists
admissionControlPluginNames := []string{"LimitRanger", "ResourceQuota"}
admissionController := admission.NewFromPlugins(kubeClient, admissionControlPluginNames, "")

kmaster := &kubernetes.MasterConfig{
MasterIP: masterIP,
MasterPort: cfg.MasterAddr.Port,
Expand All @@ -53,7 +65,7 @@ func (cfg Config) BuildKubernetesMasterConfig(requestContextMapper kapi.RequestC
EtcdHelper: ketcdHelper,
KubeClient: kubeClient,
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
AdmissionControl: admissionController,
}

return kmaster, nil
Expand Down
7 changes: 5 additions & 2 deletions pkg/cmd/server/origin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
kutil "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"

"github.com/openshift/origin/pkg/api/latest"
"github.com/openshift/origin/pkg/auth/authenticator"
Expand Down Expand Up @@ -117,6 +116,10 @@ func BuildMasterConfig(configParams MasterConfigParameters) (*MasterConfig, erro
policyCache := configParams.newPolicyCache()
requestContextMapper := kapi.NewRequestContextMapper()

// in-order list of plug-ins that should intercept admission decisions (origin only intercepts)
admissionControlPluginNames := []string{"AlwaysAdmit"}
admissionController := admission.NewFromPlugins(configParams.KubeClient, admissionControlPluginNames, "")

config := &MasterConfig{
MasterConfigParameters: configParams,

Expand All @@ -129,7 +132,7 @@ func BuildMasterConfig(configParams MasterConfigParameters) (*MasterConfig, erro

RequestContextMapper: requestContextMapper,

AdmissionControl: admit.NewAlwaysAdmit(),
AdmissionControl: admissionController,

TLS: strings.HasPrefix(configParams.MasterAddr, "https://"),
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ import (
"github.com/openshift/origin/pkg/cmd/server/etcd"
"github.com/openshift/origin/pkg/cmd/server/kubernetes"
"github.com/openshift/origin/pkg/cmd/server/origin"

// Admission control plugins from upstream Kubernetes
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/limitranger"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/namespace/exists"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/resourcedefaults"
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/resourcequota"
)

const (
Expand Down