reconcilers.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Copyright 2017 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 reconcilers Endpoint Reconcilers for the apiserver
  14. package reconcilers
  15. import (
  16. "net"
  17. corev1 "k8s.io/api/core/v1"
  18. )
  19. // EndpointReconciler knows how to reconcile the endpoints for the apiserver service.
  20. type EndpointReconciler interface {
  21. // ReconcileEndpoints sets the endpoints for the given apiserver service (ro or rw).
  22. // ReconcileEndpoints expects that the endpoints objects it manages will all be
  23. // managed only by ReconcileEndpoints; therefore, to understand this, you need only
  24. // understand the requirements.
  25. //
  26. // Requirements:
  27. // * All apiservers MUST use the same ports for their {rw, ro} services.
  28. // * All apiservers MUST use ReconcileEndpoints and only ReconcileEndpoints to manage the
  29. // endpoints for their {rw, ro} services.
  30. // * ReconcileEndpoints is called periodically from all apiservers.
  31. ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error
  32. // RemoveEndpoints removes this apiserver's lease.
  33. RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error
  34. // StopReconciling turns any later ReconcileEndpoints call into a noop.
  35. StopReconciling()
  36. }
  37. // Type the reconciler type
  38. type Type string
  39. const (
  40. // MasterCountReconcilerType will select the original reconciler
  41. MasterCountReconcilerType Type = "master-count"
  42. // LeaseEndpointReconcilerType will select a storage based reconciler
  43. LeaseEndpointReconcilerType = "lease"
  44. // NoneEndpointReconcilerType will turn off the endpoint reconciler
  45. NoneEndpointReconcilerType = "none"
  46. )
  47. // Types an array of reconciler types
  48. type Types []Type
  49. // AllTypes export all reconcilers
  50. var AllTypes = Types{
  51. MasterCountReconcilerType,
  52. LeaseEndpointReconcilerType,
  53. NoneEndpointReconcilerType,
  54. }
  55. // Names returns a slice of all the reconciler names
  56. func (t Types) Names() []string {
  57. strs := make([]string, len(t))
  58. for i, v := range t {
  59. strs[i] = string(v)
  60. }
  61. return strs
  62. }