2015-12-09 22:43:42 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-12-09 22:43:42 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package benchmark
|
|
|
|
|
|
|
|
import (
|
2017-06-22 18:24:23 +00:00
|
|
|
"k8s.io/api/core/v1"
|
2017-06-23 20:56:37 +00:00
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
2017-01-19 18:27:59 +00:00
|
|
|
restclient "k8s.io/client-go/rest"
|
2017-07-11 01:10:34 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/testapi"
|
2018-01-04 02:12:18 +00:00
|
|
|
"k8s.io/kubernetes/pkg/scheduler"
|
|
|
|
_ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
2018-02-27 19:49:58 +00:00
|
|
|
"k8s.io/kubernetes/test/integration/util"
|
2015-12-09 22:43:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// mustSetupScheduler starts the following components:
|
|
|
|
// - k8s api server (a.k.a. master)
|
|
|
|
// - scheduler
|
|
|
|
// It returns scheduler config factory and destroyFunc which should be used to
|
|
|
|
// remove resources after finished.
|
|
|
|
// Notes on rate limiter:
|
|
|
|
// - client rate limit is set to 5000.
|
2018-02-27 19:49:58 +00:00
|
|
|
func mustSetupScheduler() (scheduler.Configurator, util.ShutdownFunc) {
|
|
|
|
apiURL, apiShutdown := util.StartApiserver()
|
2016-10-05 08:40:39 +00:00
|
|
|
clientSet := clientset.NewForConfigOrDie(&restclient.Config{
|
2018-02-27 19:49:58 +00:00
|
|
|
Host: apiURL,
|
2017-07-11 01:10:34 +00:00
|
|
|
ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[v1.GroupName].GroupVersion()},
|
2015-12-25 23:05:01 +00:00
|
|
|
QPS: 5000.0,
|
|
|
|
Burst: 5000,
|
2015-12-09 22:43:42 +00:00
|
|
|
})
|
2018-02-27 19:49:58 +00:00
|
|
|
schedulerConfig, schedulerShutdown := util.StartScheduler(clientSet, true)
|
2015-12-09 22:43:42 +00:00
|
|
|
|
2018-02-27 19:49:58 +00:00
|
|
|
shutdownFunc := func() {
|
|
|
|
schedulerShutdown()
|
|
|
|
apiShutdown()
|
2015-12-09 22:43:42 +00:00
|
|
|
}
|
2018-02-27 19:49:58 +00:00
|
|
|
return schedulerConfig, shutdownFunc
|
2015-12-09 22:43:42 +00:00
|
|
|
}
|