Skip to content

Commit

Permalink
Merge pull request #559 from Xieql/pipeline-controller
Browse files Browse the repository at this point in the history
pipeline: init pipeline controller
  • Loading branch information
kurator-bot authored Jan 17, 2024
2 parents 7cd1d2f + 320fe6e commit fded0e7
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/fleet-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"kurator.dev/kurator/cmd/fleet-manager/application"
"kurator.dev/kurator/cmd/fleet-manager/backup"
"kurator.dev/kurator/cmd/fleet-manager/options"
"kurator.dev/kurator/cmd/fleet-manager/pipeline"
"kurator.dev/kurator/cmd/fleet-manager/scheme"
fleet "kurator.dev/kurator/pkg/fleet-manager"
"kurator.dev/kurator/pkg/fleet-manager/manifests"
Expand Down Expand Up @@ -146,6 +147,10 @@ func run(ctx context.Context, opts *options.Options) error {
return fmt.Errorf("backup init controllers fail, %w", err)
}

if err = pipeline.InitControllers(ctx, opts, mgr); err != nil {
return fmt.Errorf("pipeline init controllers fail, %w", err)
}

log.Info("starting manager", "version", version.Get().String())
if err := mgr.Start(ctx); err != nil {
log.Error(err, "running manager error")
Expand Down
39 changes: 39 additions & 0 deletions cmd/fleet-manager/pipeline/pipeline.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright Kurator 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 pipeline

import (
"context"

"istio.io/istio/pkg/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"

"kurator.dev/kurator/cmd/fleet-manager/options"
"kurator.dev/kurator/pkg/fleet-manager/pipeline"
)

var log = ctrl.Log.WithName("pipeline")

func InitControllers(ctx context.Context, opts *options.Options, mgr ctrl.Manager) error {
if err := (&pipeline.PipelineManager{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: opts.Concurrency, RecoverPanic: ptr.Of[bool](true)}); err != nil {
log.Error(err, "unable to create controller", "controller", "Pipeline")
return err
}

return nil
}
2 changes: 2 additions & 0 deletions cmd/fleet-manager/scheme/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
backupapi "kurator.dev/kurator/pkg/apis/backups/v1alpha1"
clusterv1alpha1 "kurator.dev/kurator/pkg/apis/cluster/v1alpha1"
fleetapi "kurator.dev/kurator/pkg/apis/fleet/v1alpha1"
pipelineapi "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1"
)

var (
Expand All @@ -38,4 +39,5 @@ func init() {
_ = hrapiv2b1.AddToScheme(Scheme)
_ = applicationapi.AddToScheme(Scheme)
_ = backupapi.AddToScheme(Scheme)
_ = pipelineapi.AddToScheme(Scheme)
}
Loading

0 comments on commit fded0e7

Please sign in to comment.