|
| 1 | +# KEP-3685: Move EndpointSlice Reconciler into Staging |
| 2 | + |
| 3 | +<!-- toc --> |
| 4 | +- [Release Signoff Checklist](#release-signoff-checklist) |
| 5 | +- [Summary](#summary) |
| 6 | +- [Motivation](#motivation) |
| 7 | + - [Goals](#goals) |
| 8 | + - [Non-Goals](#non-goals) |
| 9 | +- [Proposal](#proposal) |
| 10 | + - [Dependencies](#dependencies) |
| 11 | + - [Risks and Mitigations](#risks-and-mitigations) |
| 12 | +- [Design Details](#design-details) |
| 13 | + - [Test Plan](#test-plan) |
| 14 | +- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire) |
| 15 | +- [Implementation History](#implementation-history) |
| 16 | +- [Drawbacks](#drawbacks) |
| 17 | +- [Alternatives](#alternatives) |
| 18 | +<!-- /toc --> |
| 19 | + |
| 20 | +## Release Signoff Checklist |
| 21 | + |
| 22 | +Items marked with (R) are required *prior to targeting to a milestone / release*. |
| 23 | + |
| 24 | +- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR) |
| 25 | +- [ ] (R) KEP approvers have approved the KEP status as `implementable` |
| 26 | +- [ ] (R) Design details are appropriately documented |
| 27 | +- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors) |
| 28 | + - [ ] e2e Tests for all Beta API Operations (endpoints) |
| 29 | + - [ ] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) |
| 30 | + - [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free |
| 31 | +- [ ] (R) Graduation criteria is in place |
| 32 | + - [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) |
| 33 | +- [ ] (R) Production readiness review completed |
| 34 | +- [ ] (R) Production readiness review approved |
| 35 | +- [ ] "Implementation History" section is up-to-date for milestone |
| 36 | +- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io] |
| 37 | +- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes |
| 38 | + |
| 39 | +[kubernetes.io]: https://kubernetes.io/ |
| 40 | +[kubernetes/enhancements]: https://git.k8s.io/enhancements |
| 41 | +[kubernetes/kubernetes]: https://git.k8s.io/kubernetes |
| 42 | +[kubernetes/website]: https://git.k8s.io/website |
| 43 | + |
| 44 | +## Summary |
| 45 | + |
| 46 | +Move the EndpointSlice reconciler and it’s dependencies to staging so that the |
| 47 | +reconciler logic be reused by out-of-tree EndpointSlice controllers. |
| 48 | + |
| 49 | +Some changes are needed in `pkg/controller/endpointslice` to move the reconciler |
| 50 | +code to `staging/src/k8s.io/endpointslice` and then import it as Go module. |
| 51 | +These changes include making private methods public and updating the import |
| 52 | +paths. |
| 53 | + |
| 54 | +## Motivation |
| 55 | + |
| 56 | +Moving the EndpointSlice reconciler to staging has several benefits: |
| 57 | + |
| 58 | +1. The reconciler logic can be reused by custom EndpointSlice controllers. The |
| 59 | + fanout behavior is difficult to implement correctly and the current |
| 60 | + reconciler code has gone through several iterations to reach its currently |
| 61 | + level of robustness. There are cases where reconciler code has either been |
| 62 | + forked or rewritten, both of which are problematic from a supportability |
| 63 | + perspective. |
| 64 | +2. It reduces the burden of fully migrating from Endpoints to EndpointSlices. |
| 65 | + It’s relatively easy to write a custom Endpoints controller, but less so with |
| 66 | + EndpointSlices. So, the migration path is unclear for pre-existing custom |
| 67 | + Endpoints controllers. Having a library that handles the more difficult |
| 68 | + aspects of managing EndpointSlices would mitigate some of the risk in |
| 69 | + migrating these controllers. |
| 70 | +3. It would help to realize one of the design goals of EndpointSlices: that |
| 71 | + other controllers would exist to manage EndpointSlices, which is why the |
| 72 | + `endpointslice.kubernetes.io/managed-by` annotation was added. |
| 73 | + |
| 74 | +### Goals |
| 75 | + |
| 76 | +- Expose a simple, and highly maintained, API for EndpointSlice reconciling. |
| 77 | +- Allow for the EndpointSlice reconciling code to easily be imported into other |
| 78 | + projects. |
| 79 | + |
| 80 | +### Non-Goals |
| 81 | + |
| 82 | +- A generic solution for reconciling fan-out style resources. |
| 83 | +- Providing the ability for a Service to opt-out of the in-tree EndpointSlice |
| 84 | + controller. This was considered and determined to be out of scope. |
| 85 | + |
| 86 | +## Proposal |
| 87 | + |
| 88 | +1. Add the staging repository (`staging/src/k8s.io/endpointslice`) to |
| 89 | + `kubernetes/kubernetes` by following the steps in the [staging directory |
| 90 | + README][staging-readme]. |
| 91 | +2. Move the reconciler submodule and it’s [dependencies](###dependencies) to the |
| 92 | + staging directory and update imports in `pkg/controller/endpointslice`. This |
| 93 | + should be a single atomic change. |
| 94 | + - Some methods need to be made public to allow for reconciler code to be |
| 95 | + used as a library (at least `NewReconciler` and `Reconcile`). |
| 96 | +3. Allow for the value of the `endpointslice.kubernetes.io/managed-by` label to |
| 97 | + be configurable by adding `managedBy` as an argument to `NewReconciler`. |
| 98 | +4. Split computing the diff (EndpointSlices to create, update, and delete) and |
| 99 | + applying the diff into separate methods. This allows for controllers to |
| 100 | + easily add metadata to the managed EndpointSlices (e.g. adding an |
| 101 | + annotation). |
| 102 | + |
| 103 | +[staging-readme]: https://github.com/kubernetes/kubernetes/tree/master/staging "External Repository Staging Area" |
| 104 | + |
| 105 | +### Dependencies |
| 106 | + |
| 107 | +The following dependencies would also have to be moved to the staging repository |
| 108 | +(assume `staging_root = staging/src/k8s.io/endpointslice`): |
| 109 | +- `pkg/controller/endpointslice/metrics => $staging_root/metrics` |
| 110 | +- `pkg/controller/endpointslice/topologycache => $staging_root/topologycache` |
| 111 | +- `pkg/controller/util/endpoint => $staging_root/util` |
| 112 | +- `pkg/controller/util/endpointslice => $staging_root/util` |
| 113 | + |
| 114 | +The following dependencies don’t have to be moved as there’s only one trivial |
| 115 | +function used from each: |
| 116 | +- `pkg/api/v1/pod` |
| 117 | + - `IsPodReady` function can be moved to `component-helpers` as it’s also |
| 118 | + used by `kubectl`. |
| 119 | +- `pkg/apis/core/v1/helper` |
| 120 | + - `IsServiceIPSet` function can be moved to staging or mirrored. |
| 121 | +- `pkg/apis/discovery/validation` |
| 122 | + - `ValidateEndpointSliceName` is a re-export of `NameIsDNSSubdomain` from |
| 123 | + `k8s.io/apimachinery`, which is already in staging. |
| 124 | + |
| 125 | +### Risks and Mitigations |
| 126 | + |
| 127 | +Users might expect compatibility to be maintained for the library’s public API. |
| 128 | +This is a risk for all staging repositories, and the current mitigation strategy |
| 129 | +has been to clearly document that there are no compatibility guarantees in the |
| 130 | +README: |
| 131 | + |
| 132 | +> There are NO compatibility guarantees for this repository. It is in direct |
| 133 | +> support of Kubernetes, so branches will track Kubernetes and be compatible |
| 134 | +> with that repo. As we more cleanly separate the layers, we will review the |
| 135 | +> compatibility guarantee. |
| 136 | +
|
| 137 | +## Design Details |
| 138 | + |
| 139 | +### Test Plan |
| 140 | + |
| 141 | +[x] I/we understand the owners of the involved components may require updates to |
| 142 | +existing tests to make this code solid enough prior to committing the changes necessary |
| 143 | +to implement this enhancement. |
| 144 | + |
| 145 | +## Production Readiness Review Questionnaire |
| 146 | + |
| 147 | +N/A |
| 148 | + |
| 149 | +## Implementation History |
| 150 | + |
| 151 | +## Drawbacks |
| 152 | + |
| 153 | +This change will add some maintenance burden to the EndpointSlice controller as |
| 154 | +its code will be spread across `pkg/controller` and `staging`. |
| 155 | + |
| 156 | +## Alternatives |
| 157 | + |
| 158 | +Externalize the entire EndpointSlice controller and use alternate data sources |
| 159 | +(informers) to customize behavior. |
0 commit comments