k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kube-controller-manager/app/bootstrap.go (about) 1 /* 2 Copyright 2016 The Kubernetes 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 app 18 19 import ( 20 "context" 21 "fmt" 22 23 "k8s.io/controller-manager/controller" 24 "k8s.io/kubernetes/cmd/kube-controller-manager/names" 25 "k8s.io/kubernetes/pkg/controller/bootstrap" 26 ) 27 28 func newBootstrapSignerControllerDescriptor() *ControllerDescriptor { 29 return &ControllerDescriptor{ 30 name: names.BootstrapSignerController, 31 aliases: []string{"bootstrapsigner"}, 32 initFunc: startBootstrapSignerController, 33 isDisabledByDefault: true, 34 } 35 } 36 func startBootstrapSignerController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) { 37 bsc, err := bootstrap.NewSigner( 38 controllerContext.ClientBuilder.ClientOrDie("bootstrap-signer"), 39 controllerContext.InformerFactory.Core().V1().Secrets(), 40 controllerContext.InformerFactory.Core().V1().ConfigMaps(), 41 bootstrap.DefaultSignerOptions(), 42 ) 43 if err != nil { 44 return nil, true, fmt.Errorf("error creating BootstrapSigner controller: %v", err) 45 } 46 go bsc.Run(ctx) 47 return nil, true, nil 48 } 49 50 func newTokenCleanerControllerDescriptor() *ControllerDescriptor { 51 return &ControllerDescriptor{ 52 name: names.TokenCleanerController, 53 aliases: []string{"tokencleaner"}, 54 initFunc: startTokenCleanerController, 55 isDisabledByDefault: true, 56 } 57 } 58 func startTokenCleanerController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) { 59 tcc, err := bootstrap.NewTokenCleaner( 60 controllerContext.ClientBuilder.ClientOrDie("token-cleaner"), 61 controllerContext.InformerFactory.Core().V1().Secrets(), 62 bootstrap.DefaultTokenCleanerOptions(), 63 ) 64 if err != nil { 65 return nil, true, fmt.Errorf("error creating TokenCleaner controller: %v", err) 66 } 67 go tcc.Run(ctx) 68 return nil, true, nil 69 }