github.com/kubewharf/katalyst-core@v0.5.3/cmd/katalyst-controller/app/controller/tide.go (about)

     1  /*
     2  Copyright 2022 The Katalyst Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package controller
    18  
    19  import (
    20  	"context"
    21  
    22  	"k8s.io/klog/v2"
    23  
    24  	katalystbase "github.com/kubewharf/katalyst-core/cmd/base"
    25  	"github.com/kubewharf/katalyst-core/pkg/config"
    26  	"github.com/kubewharf/katalyst-core/pkg/controller/tide"
    27  )
    28  
    29  const (
    30  	TideControllerName = "tide"
    31  )
    32  
    33  func StartTideController(ctx context.Context, controlCtx *katalystbase.GenericContext,
    34  	conf *config.Configuration, _ interface{}, _ string,
    35  ) (bool, error) {
    36  	// targetHandler is initialized once and shared by multiple controllers
    37  	tideController, err := tide.NewTide(
    38  		ctx,
    39  		controlCtx,
    40  		conf.GenericConfiguration,
    41  		conf.GenericControllerConfiguration,
    42  	)
    43  	if err != nil {
    44  		klog.Errorf("failed to new kcc controller")
    45  		return false, err
    46  	}
    47  
    48  	go tideController.Run()
    49  	return true, nil
    50  }