Skip to content

Commit 549c61d

Browse files
authored
Merge pull request #527 from czybjtu/feat_elasticquota_ctrl
feat: migrate elasticquota controller to ctrl runtime
2 parents 55c0bb9 + c5f2698 commit 549c61d

File tree

10 files changed

+290
-462
lines changed

10 files changed

+290
-462
lines changed

cmd/controller/app/server.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"sigs.k8s.io/controller-runtime/pkg/healthz"
4040

4141
schedulingv1a1 "sigs.k8s.io/scheduler-plugins/apis/scheduling/v1alpha1"
42-
"sigs.k8s.io/scheduler-plugins/pkg/controller"
4342
"sigs.k8s.io/scheduler-plugins/pkg/controllers"
4443
schedclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned"
4544
schedformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions"
@@ -86,11 +85,8 @@ func Run(s *ServerRunOptions) error {
8685
kubeClient := kubernetes.NewForConfigOrDie(config)
8786

8887
schedInformerFactory := schedformers.NewSharedInformerFactory(schedClient, 0)
89-
eqInformer := schedInformerFactory.Scheduling().V1alpha1().ElasticQuotas()
9088

9189
coreInformerFactory := informers.NewSharedInformerFactory(kubeClient, 0)
92-
podInformer := coreInformerFactory.Core().V1().Pods()
93-
eqCtrl := controller.NewElasticQuotaController(kubeClient, eqInformer, podInformer, schedClient)
9490

9591
// Controller Runtime Controllers
9692
ctrl.SetLogger(klogr.New())
@@ -116,6 +112,14 @@ func Run(s *ServerRunOptions) error {
116112
return err
117113
}
118114

115+
if err = (&controllers.ElasticQuotaReconciler{
116+
Client: mgr.GetClient(),
117+
Scheme: mgr.GetScheme(),
118+
}).SetupWithManager(mgr); err != nil {
119+
setupLog.Error(err, "unable to create controller", "controller", "ElasticQuota")
120+
return err
121+
}
122+
119123
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
120124
setupLog.Error(err, "unable to set up health check")
121125
return err
@@ -126,7 +130,6 @@ func Run(s *ServerRunOptions) error {
126130
}
127131

128132
run := func(ctx context.Context) {
129-
go eqCtrl.Run(s.Workers, ctx.Done())
130133
setupLog.Info("starting manager")
131134
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
132135
setupLog.Error(err, "unable to start manager")

manifests/install/all-in-one.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ rules:
5353
- apiGroups: ["scheduling.x-k8s.io"]
5454
resources: ["podgroups", "elasticquotas", "podgroups/status", "elasticquotas/status"]
5555
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
56+
- apiGroups: [""]
57+
resources: ["events"]
58+
verbs: ["create", "patch", "update"]
5659
---
5760
kind: ClusterRoleBinding
5861
apiVersion: rbac.authorization.k8s.io/v1

manifests/install/charts/as-a-second-scheduler/templates/rbac.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ rules:
9595
- apiGroups: [""]
9696
resources: ["pods"]
9797
verbs: ["get", "list", "watch"]
98+
- apiGroups: [""]
99+
resources: ["events"]
100+
verbs: ["create", "patch", "update"]
98101
- apiGroups: [""]
99102
resources: ["nodes"]
100103
verbs: ["get", "list", "watch", "patch"]

0 commit comments

Comments
 (0)