github.com/kubewharf/katalyst-core@v0.5.3/cmd/katalyst-controller/app/controller/vpa.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 katalyst "github.com/kubewharf/katalyst-core/cmd/base" 25 "github.com/kubewharf/katalyst-core/pkg/config" 26 "github.com/kubewharf/katalyst-core/pkg/controller/vpa" 27 ) 28 29 const ( 30 VPAControllerName = "vpa" 31 ) 32 33 func StartVPAController(ctx context.Context, controlCtx *katalyst.GenericContext, 34 conf *config.Configuration, _ interface{}, _ string, 35 ) (bool, error) { 36 r, err := vpa.NewResourceRecommendController(ctx, controlCtx, 37 conf.GenericConfiguration, 38 conf.GenericControllerConfiguration, 39 conf.ControllersConfiguration.VPAConfig) 40 if err != nil { 41 klog.Errorf("failed to new resource recommend controller") 42 return false, err 43 } 44 45 vr, err := vpa.NewVPARecommendationController(ctx, controlCtx, 46 conf.GenericConfiguration, 47 conf.GenericControllerConfiguration, 48 conf.ControllersConfiguration.VPAConfig) 49 if err != nil { 50 klog.Errorf("failed to new vpa recommendatin controller") 51 return false, err 52 } 53 54 v, err := vpa.NewVPAController(ctx, controlCtx, 55 conf.GenericConfiguration, 56 conf.GenericControllerConfiguration, 57 conf.ControllersConfiguration.VPAConfig) 58 if err != nil { 59 klog.Errorf("failed to new vpa controller") 60 return false, err 61 } 62 63 go r.Run() 64 go v.Run() 65 go vr.Run() 66 return true, nil 67 }