Skip to content
Open
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
5 changes: 5 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -264,10 +265,14 @@ func main() {
setupLog.Error(err, "unable to add home cluster")
os.Exit(1)
}
hvGVK := schema.GroupVersionKind{Group: "kvm.cloud.sap", Version: "v1", Kind: "Hypervisor"}
multiclusterClient := &multicluster.Client{
HomeCluster: homeCluster,
HomeRestConfig: restConfig,
HomeScheme: scheme,
ResourceRouters: map[schema.GroupVersionKind]multicluster.ResourceRouter{
hvGVK: multicluster.HypervisorResourceRouter{},
},
}
multiclusterClientConfig := conf.GetConfigOrDie[multicluster.ClientConfig]()
if err := multiclusterClient.InitFromConf(ctx, mgr, multiclusterClientConfig); err != nil {
Expand Down
18 changes: 18 additions & 0 deletions helm/bundles/cortex-cinder/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ cortex: &cortex
prometheus: {enable: false}
conf: &cortexConf
schedulingDomain: cinder
apiservers:
home:
gvks:
- cortex.cloud/v1alpha1/Decision
- cortex.cloud/v1alpha1/DecisionList
- cortex.cloud/v1alpha1/Descheduling
- cortex.cloud/v1alpha1/DeschedulingList
- cortex.cloud/v1alpha1/Pipeline
- cortex.cloud/v1alpha1/PipelineList
- cortex.cloud/v1alpha1/Knowledge
- cortex.cloud/v1alpha1/KnowledgeList
- cortex.cloud/v1alpha1/Datasource
- cortex.cloud/v1alpha1/DatasourceList
- cortex.cloud/v1alpha1/KPI
- cortex.cloud/v1alpha1/KPIList
- cortex.cloud/v1alpha1/Reservation
- cortex.cloud/v1alpha1/ReservationList
- v1/Secret
keystoneSecretRef:
name: cortex-cinder-openstack-keystone
namespace: default
Expand Down
24 changes: 24 additions & 0 deletions helm/bundles/cortex-ironcore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ cortex:
conf:
# The operator will only touch CRs with this scheduling domain name.
schedulingDomain: machines
apiservers:
home:
gvks:
- cortex.cloud/v1alpha1/Decision
- cortex.cloud/v1alpha1/DecisionList
- cortex.cloud/v1alpha1/Descheduling
- cortex.cloud/v1alpha1/DeschedulingList
- cortex.cloud/v1alpha1/Pipeline
- cortex.cloud/v1alpha1/PipelineList
- cortex.cloud/v1alpha1/Knowledge
- cortex.cloud/v1alpha1/KnowledgeList
- cortex.cloud/v1alpha1/Datasource
- cortex.cloud/v1alpha1/DatasourceList
- cortex.cloud/v1alpha1/KPI
- cortex.cloud/v1alpha1/KPIList
- cortex.cloud/v1alpha1/Reservation
- cortex.cloud/v1alpha1/ReservationList
- compute.ironcore.dev/v1alpha1/Machine
- compute.ironcore.dev/v1alpha1/MachineList
- compute.ironcore.dev/v1alpha1/MachinePool
- compute.ironcore.dev/v1alpha1/MachinePoolList
- compute.ironcore.dev/v1alpha1/MachineClass
- compute.ironcore.dev/v1alpha1/MachineClassList
- v1/Secret
enabledControllers:
- ironcore-decisions-pipeline-controller
- explanation-controller
Expand Down
18 changes: 18 additions & 0 deletions helm/bundles/cortex-manila/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ cortex: &cortex
prometheus: {enable: false}
conf: &cortexConf
schedulingDomain: manila
apiservers:
home:
gvks:
- cortex.cloud/v1alpha1/Decision
- cortex.cloud/v1alpha1/DecisionList
- cortex.cloud/v1alpha1/Descheduling
- cortex.cloud/v1alpha1/DeschedulingList
- cortex.cloud/v1alpha1/Pipeline
- cortex.cloud/v1alpha1/PipelineList
- cortex.cloud/v1alpha1/Knowledge
- cortex.cloud/v1alpha1/KnowledgeList
- cortex.cloud/v1alpha1/Datasource
- cortex.cloud/v1alpha1/DatasourceList
- cortex.cloud/v1alpha1/KPI
- cortex.cloud/v1alpha1/KPIList
- cortex.cloud/v1alpha1/Reservation
- cortex.cloud/v1alpha1/ReservationList
- v1/Secret
keystoneSecretRef:
name: cortex-manila-openstack-keystone
namespace: default
Expand Down
20 changes: 20 additions & 0 deletions helm/bundles/cortex-nova/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ cortex: &cortex
prometheus: {enable: false}
conf: &cortexConf
schedulingDomain: nova
apiservers:
home:
gvks:
- cortex.cloud/v1alpha1/Decision
- cortex.cloud/v1alpha1/DecisionList
- cortex.cloud/v1alpha1/Descheduling
- cortex.cloud/v1alpha1/DeschedulingList
- cortex.cloud/v1alpha1/Pipeline
- cortex.cloud/v1alpha1/PipelineList
- cortex.cloud/v1alpha1/Knowledge
- cortex.cloud/v1alpha1/KnowledgeList
- cortex.cloud/v1alpha1/Datasource
- cortex.cloud/v1alpha1/DatasourceList
- cortex.cloud/v1alpha1/KPI
- cortex.cloud/v1alpha1/KPIList
- cortex.cloud/v1alpha1/Reservation
- cortex.cloud/v1alpha1/ReservationList
- kvm.cloud.sap/v1/Hypervisor
- kvm.cloud.sap/v1/HypervisorList
- v1/Secret
keystoneSecretRef:
name: cortex-nova-openstack-keystone
namespace: default
Expand Down
21 changes: 21 additions & 0 deletions helm/bundles/cortex-pods/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ cortex:
conf:
# The operator will only touch CRs with this scheduling domain name.
schedulingDomain: pods
apiservers:
home:
gvks:
- cortex.cloud/v1alpha1/Decision
- cortex.cloud/v1alpha1/DecisionList
- cortex.cloud/v1alpha1/Descheduling
- cortex.cloud/v1alpha1/DeschedulingList
- cortex.cloud/v1alpha1/Pipeline
- cortex.cloud/v1alpha1/PipelineList
- cortex.cloud/v1alpha1/Knowledge
- cortex.cloud/v1alpha1/KnowledgeList
- cortex.cloud/v1alpha1/Datasource
- cortex.cloud/v1alpha1/DatasourceList
- cortex.cloud/v1alpha1/KPI
- cortex.cloud/v1alpha1/KPIList
- cortex.cloud/v1alpha1/Reservation
- cortex.cloud/v1alpha1/ReservationList
- v1/Secret
- v1/Pod
- v1/NodeList
- v1/Binding
enabledControllers:
- pods-decisions-pipeline-controller
- explanation-controller
Expand Down
46 changes: 26 additions & 20 deletions internal/knowledge/extractor/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,31 @@ func (r *TriggerReconciler) mapKnowledgeToKnowledge(ctx context.Context, obj cli

// SetupWithManager sets up the controller with the Manager
func (r *TriggerReconciler) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error {
return multicluster.BuildController(mcl, mgr).
// Watch datasource changes and map them to trigger reconciliation
WatchesMulticluster(
&v1alpha1.Datasource{},
handler.EnqueueRequestsFromMapFunc(r.mapDatasourceToKnowledge),
predicate.NewPredicateFuncs(func(obj client.Object) bool {
ds := obj.(*v1alpha1.Datasource)
return ds.Spec.SchedulingDomain == r.Conf.SchedulingDomain
}),
).
// Watch knowledge changes and map them to trigger reconciliation
WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.EnqueueRequestsFromMapFunc(r.mapKnowledgeToKnowledge),
predicate.NewPredicateFuncs(func(obj client.Object) bool {
k := obj.(*v1alpha1.Knowledge)
return k.Spec.SchedulingDomain == r.Conf.SchedulingDomain
}),
).
Named("cortex-knowledge-trigger").
bldr := multicluster.BuildController(mcl, mgr)
// Watch datasource changes and map them to trigger reconciliation
bldr, err := bldr.WatchesMulticluster(
&v1alpha1.Datasource{},
handler.EnqueueRequestsFromMapFunc(r.mapDatasourceToKnowledge),
predicate.NewPredicateFuncs(func(obj client.Object) bool {
ds := obj.(*v1alpha1.Datasource)
return ds.Spec.SchedulingDomain == r.Conf.SchedulingDomain
}),
)
if err != nil {
return err
}
// Watch knowledge changes and map them to trigger reconciliation
bldr, err = bldr.WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.EnqueueRequestsFromMapFunc(r.mapKnowledgeToKnowledge),
predicate.NewPredicateFuncs(func(obj client.Object) bool {
k := obj.(*v1alpha1.Knowledge)
return k.Spec.SchedulingDomain == r.Conf.SchedulingDomain
}),
)
if err != nil {
return err
}
return bldr.Named("cortex-knowledge-trigger").
Complete(r)
}
66 changes: 36 additions & 30 deletions internal/knowledge/kpis/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,36 +443,42 @@ func (c *Controller) SetupWithManager(mgr manager.Manager, mcl *multicluster.Cli
if err := mgr.Add(manager.RunnableFunc(c.InitAllKPIs)); err != nil {
return err
}
return multicluster.BuildController(mcl, mgr).
// Watch datasource changes so that we can reconfigure kpis as needed.
WatchesMulticluster(
&v1alpha1.Datasource{},
handler.Funcs{
CreateFunc: c.handleDatasourceCreated,
UpdateFunc: c.handleDatasourceUpdated,
DeleteFunc: c.handleDatasourceDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
// Only react to datasources matching the scheduling domain.
ds := obj.(*v1alpha1.Datasource)
return ds.Spec.SchedulingDomain == c.Config.SchedulingDomain
}),
).
// Watch knowledge changes so that we can reconfigure kpis as needed.
WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.Funcs{
CreateFunc: c.handleKnowledgeCreated,
UpdateFunc: c.handleKnowledgeUpdated,
DeleteFunc: c.handleKnowledgeDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
// Only react to knowledges matching the scheduling domain.
kn := obj.(*v1alpha1.Knowledge)
return kn.Spec.SchedulingDomain == c.Config.SchedulingDomain
}),
).
Named("cortex-kpis").
bldr := multicluster.BuildController(mcl, mgr)
// Watch datasource changes so that we can reconfigure kpis as needed.
bldr, err := bldr.WatchesMulticluster(
&v1alpha1.Datasource{},
handler.Funcs{
CreateFunc: c.handleDatasourceCreated,
UpdateFunc: c.handleDatasourceUpdated,
DeleteFunc: c.handleDatasourceDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
// Only react to datasources matching the scheduling domain.
ds := obj.(*v1alpha1.Datasource)
return ds.Spec.SchedulingDomain == c.Config.SchedulingDomain
}),
)
if err != nil {
return err
}
// Watch knowledge changes so that we can reconfigure kpis as needed.
bldr, err = bldr.WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.Funcs{
CreateFunc: c.handleKnowledgeCreated,
UpdateFunc: c.handleKnowledgeUpdated,
DeleteFunc: c.handleKnowledgeDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
// Only react to knowledges matching the scheduling domain.
kn := obj.(*v1alpha1.Knowledge)
return kn.Spec.SchedulingDomain == c.Config.SchedulingDomain
}),
)
if err != nil {
return err
}
return bldr.Named("cortex-kpis").
For(
&v1alpha1.KPI{},
builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool {
Expand Down
98 changes: 52 additions & 46 deletions internal/scheduling/cinder/filter_weigher_pipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,52 +159,58 @@ func (c *FilterWeigherPipelineController) SetupWithManager(mgr manager.Manager,
if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil {
return err
}
return multicluster.BuildController(mcl, mgr).
// Watch pipeline changes so that we can reconfigure pipelines as needed.
WatchesMulticluster(
&v1alpha1.Pipeline{},
handler.Funcs{
CreateFunc: c.HandlePipelineCreated,
UpdateFunc: c.HandlePipelineUpdated,
DeleteFunc: c.HandlePipelineDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
pipeline := obj.(*v1alpha1.Pipeline)
// Only react to pipelines matching the scheduling domain.
if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder {
return false
}
return pipeline.Spec.Type == c.PipelineType()
}),
).
// Watch knowledge changes so that we can reconfigure pipelines as needed.
WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.Funcs{
CreateFunc: c.HandleKnowledgeCreated,
UpdateFunc: c.HandleKnowledgeUpdated,
DeleteFunc: c.HandleKnowledgeDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
knowledge := obj.(*v1alpha1.Knowledge)
// Only react to knowledge matching the scheduling domain.
return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainCinder
}),
).
For(
&v1alpha1.Decision{},
builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool {
decision := obj.(*v1alpha1.Decision)
if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder {
return false
}
// Ignore already decided schedulings.
if decision.Status.Result != nil {
return false
}
return true
})),
).
bldr := multicluster.BuildController(mcl, mgr)
// Watch pipeline changes so that we can reconfigure pipelines as needed.
bldr, err := bldr.WatchesMulticluster(
&v1alpha1.Pipeline{},
handler.Funcs{
CreateFunc: c.HandlePipelineCreated,
UpdateFunc: c.HandlePipelineUpdated,
DeleteFunc: c.HandlePipelineDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
pipeline := obj.(*v1alpha1.Pipeline)
// Only react to pipelines matching the scheduling domain.
if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder {
return false
}
return pipeline.Spec.Type == c.PipelineType()
}),
)
if err != nil {
return err
}
// Watch knowledge changes so that we can reconfigure pipelines as needed.
bldr, err = bldr.WatchesMulticluster(
&v1alpha1.Knowledge{},
handler.Funcs{
CreateFunc: c.HandleKnowledgeCreated,
UpdateFunc: c.HandleKnowledgeUpdated,
DeleteFunc: c.HandleKnowledgeDeleted,
},
predicate.NewPredicateFuncs(func(obj client.Object) bool {
knowledge := obj.(*v1alpha1.Knowledge)
// Only react to knowledge matching the scheduling domain.
return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainCinder
}),
)
if err != nil {
return err
}
return bldr.For(
&v1alpha1.Decision{},
builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool {
decision := obj.(*v1alpha1.Decision)
if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder {
return false
}
// Ignore already decided schedulings.
if decision.Status.Result != nil {
return false
}
return true
})),
).
Named("cortex-cinder-decisions").
Complete(c)
}
Loading