discovery.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 implements a server that runs a set of active
  14. // components. This includes replication controllers, service endpoints and
  15. // nodes.
  16. //
  17. package app
  18. import (
  19. "net/http"
  20. discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
  21. utilfeature "k8s.io/apiserver/pkg/util/feature"
  22. "k8s.io/klog"
  23. endpointslicecontroller "k8s.io/kubernetes/pkg/controller/endpointslice"
  24. "k8s.io/kubernetes/pkg/features"
  25. )
  26. func startEndpointSliceController(ctx ControllerContext) (http.Handler, bool, error) {
  27. if !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSlice) {
  28. klog.V(4).Infof("Not starting endpointslice-controller since EndpointSlice feature gate is disabled")
  29. return nil, false, nil
  30. }
  31. if !ctx.AvailableResources[discoveryv1beta1.SchemeGroupVersion.WithResource("endpointslices")] {
  32. klog.Warningf("Not starting endpointslice-controller since discovery.k8s.io/v1beta1 resources are not available")
  33. return nil, false, nil
  34. }
  35. go endpointslicecontroller.NewController(
  36. ctx.InformerFactory.Core().V1().Pods(),
  37. ctx.InformerFactory.Core().V1().Services(),
  38. ctx.InformerFactory.Core().V1().Nodes(),
  39. ctx.InformerFactory.Discovery().V1beta1().EndpointSlices(),
  40. ctx.ComponentConfig.EndpointSliceController.MaxEndpointsPerSlice,
  41. ctx.ClientBuilder.ClientOrDie("endpointslice-controller"),
  42. ).Run(int(ctx.ComponentConfig.EndpointSliceController.ConcurrentServiceEndpointSyncs), ctx.Stop)
  43. return nil, true, nil
  44. }