forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunidling.go
38 lines (30 loc) · 1.16 KB
/
unidling.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
package controller
import (
"time"
appstypedclient "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1"
appsv1client "github.com/openshift/origin/pkg/apps/client/v1"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
unidlingcontroller "github.com/openshift/origin/pkg/unidling/controller"
)
func RunUnidlingController(ctx *ControllerContext) (bool, error) {
// TODO this should be configurable
resyncPeriod := 2 * time.Hour
clientConfig := ctx.ClientBuilder.ConfigOrDie(bootstrappolicy.InfraUnidlingControllerServiceAccountName)
appsClient, err := appstypedclient.NewForConfig(clientConfig)
if err != nil {
return false, err
}
scaleNamespacer := appsv1client.NewDelegatingScaleNamespacer(appsClient,
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraUnidlingControllerServiceAccountName).ExtensionsV1beta1())
coreClient := ctx.ClientBuilder.KubeInternalClientOrDie(bootstrappolicy.InfraUnidlingControllerServiceAccountName).Core()
controller := unidlingcontroller.NewUnidlingController(
scaleNamespacer,
coreClient,
coreClient,
appsClient,
coreClient,
resyncPeriod,
)
go controller.Run(ctx.Stop)
return true, nil
}