mirror of
https://github.com/hanzo-ml/trainer.git
synced 2026-09-24 00:31:34 +00:00
* chore(deps): Bump Go 1.25, k8s to v1.35, and controller-runtime v0.23.1 Signed-off-by: Andrey Velichkevich <[email protected]> * Migrate to new events API with EventRecorder Signed-off-by: Andrey Velichkevich <[email protected]> * Fix RBAC for events Signed-off-by: Andrey Velichkevich <[email protected]> * Bump k8s version in tests Signed-off-by: Andrey Velichkevich <[email protected]> * Add type compliance check Signed-off-by: Andrey Velichkevich <[email protected]> * Use Reconciling action for event Signed-off-by: Andrey Velichkevich <[email protected]> --------- Signed-off-by: Andrey Velichkevich <[email protected]>
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
/*
|
|
Copyright 2024 The Kubeflow Authors.
|
|
|
|
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 controller
|
|
|
|
import (
|
|
ctrl "sigs.k8s.io/controller-runtime"
|
|
"sigs.k8s.io/controller-runtime/pkg/controller"
|
|
|
|
trainer "github.com/kubeflow/trainer/v2/pkg/apis/trainer/v1alpha1"
|
|
"github.com/kubeflow/trainer/v2/pkg/runtime"
|
|
)
|
|
|
|
func SetupControllers(mgr ctrl.Manager, runtimes map[string]runtime.Runtime, options controller.Options) (string, error) {
|
|
runtimeRec := NewTrainingRuntimeReconciler(
|
|
mgr.GetClient(),
|
|
mgr.GetEventRecorder("trainer-trainingruntime-controller"),
|
|
)
|
|
if err := runtimeRec.SetupWithManager(mgr, options); err != nil {
|
|
return trainer.TrainingRuntimeKind, err
|
|
}
|
|
clRuntimeRec := NewClusterTrainingRuntimeReconciler(
|
|
mgr.GetClient(),
|
|
mgr.GetEventRecorder("trainer-clustertrainingruntime-controller"),
|
|
)
|
|
if err := clRuntimeRec.SetupWithManager(mgr, options); err != nil {
|
|
return trainer.ClusterTrainingRuntimeKind, err
|
|
}
|
|
if err := NewTrainJobReconciler(
|
|
mgr.GetClient(),
|
|
mgr.GetEventRecorder("trainer-trainjob-controller"),
|
|
runtimes,
|
|
WithWatchers(runtimeRec, clRuntimeRec),
|
|
).SetupWithManager(mgr, options); err != nil {
|
|
return trainer.TrainJobKind, err
|
|
}
|
|
return "", nil
|
|
}
|