bootstrap.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package app
  14. import (
  15. "fmt"
  16. "net/http"
  17. "k8s.io/kubernetes/pkg/controller/bootstrap"
  18. )
  19. func startBootstrapSignerController(ctx ControllerContext) (http.Handler, bool, error) {
  20. bsc, err := bootstrap.NewSigner(
  21. ctx.ClientBuilder.ClientOrDie("bootstrap-signer"),
  22. ctx.InformerFactory.Core().V1().Secrets(),
  23. ctx.InformerFactory.Core().V1().ConfigMaps(),
  24. bootstrap.DefaultSignerOptions(),
  25. )
  26. if err != nil {
  27. return nil, true, fmt.Errorf("error creating BootstrapSigner controller: %v", err)
  28. }
  29. go bsc.Run(ctx.Stop)
  30. return nil, true, nil
  31. }
  32. func startTokenCleanerController(ctx ControllerContext) (http.Handler, bool, error) {
  33. tcc, err := bootstrap.NewTokenCleaner(
  34. ctx.ClientBuilder.ClientOrDie("token-cleaner"),
  35. ctx.InformerFactory.Core().V1().Secrets(),
  36. bootstrap.DefaultTokenCleanerOptions(),
  37. )
  38. if err != nil {
  39. return nil, true, fmt.Errorf("error creating TokenCleaner controller: %v", err)
  40. }
  41. go tcc.Run(ctx.Stop)
  42. return nil, true, nil
  43. }