Skip to content

Commit bb99405

Browse files
authored
Merge pull request #2515 from luxas/graduate_config_kep
Move the ComponentConfig types to staging KEP to implementable
2 parents ee5f12e + f5ce814 commit bb99405

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

keps/sig-cluster-lifecycle/0014-20180707-componentconfig-api-types-to-staging.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
kep-number: 17
33
title: Moving ComponentConfig API types to staging repos
4-
status: provisional
4+
status: implementable
55
authors:
66
- "@luxas"
77
- "@sttts"
@@ -25,7 +25,7 @@ approvers:
2525
editor:
2626
name: "@luxas"
2727
creation-date: 2018-07-07
28-
last-updated: 2018-07-07
28+
last-updated: 2018-08-10
2929
---
3030

3131
# Moving ComponentConfig API types to staging repos
@@ -127,7 +127,7 @@ types of the core components’ ComponentConfig in a top-level `config/` package
127127
### Non-goals
128128

129129
* Graduate the API versions
130-
* For v1.12, we’re working incrementally and will keep the versions of the existing ComponentConfigs.
130+
* For v1.12, we’re working incrementally and will keep the API versions of the existing ComponentConfigs.
131131
* Do major refactoring of the ComponentConfigs. This PR is about code moves, not about re-defining the structure. We will do the latter in follow-ups.
132132
* Change the components to support reading a config file, do flag precedence correctly or add e2e testing
133133
* Further, the "load-versioned-config-from-flag" feature in this proposal *should not* be confused with the
@@ -143,7 +143,14 @@ types of the core components’ ComponentConfig in a top-level `config/` package
143143
make the command support loading configuration files.
144144
* The new repo can reuse the generic types from the to-be-created, `k8s.io/controller-manager` repo eventually.
145145
* Meanwhile, the cloud-controller-manager will reference the parts it needs from the main repo, and live privately in `cmd/cloud-controller-manager`
146-
* Add further defaulting for the external types. The defaulting strategy decision is post-poned, outside of this KEP.
146+
* Expose defaulting functions for the external ComponentConfig types in `k8s.io/{component}/config` packages.
147+
* Defaulting functions will still live local to the component in e.g. `k8s.io/kubernetes/pkg/{component}/apis/config/{version}` and be
148+
registered in the default scheme, but won't be publicly exposed in the `k8s.io/{component}` repo.
149+
* The only defaulting functions that are published to non-core repos are for the shared config types, in other words in
150+
`k8s.io/{apimachinery,apiserver,controller-manager}/pkg/apis/config/{version}`, but **they are not registered in the scheme by default**
151+
(with the normal `SetDefault_Foo` method and the `addDefaultingFunc(scheme *runtime.Scheme) { return RegisterDefaults(scheme) }` function).
152+
Instead, there will be `RecommendedDefaultFoo` methods exposed, which the consumer of the shared types may or may not manually run in
153+
`SetDefaults_Bar` functions (where `Bar` wraps `Foo` as a field).
147154

148155
### Related proposals and further references
149156

@@ -167,23 +174,30 @@ types of the core components’ ComponentConfig in a top-level `config/` package
167174
* Like `k8s.io/api`
168175
* Internal types: `k8s.io/kubernetes/pkg/{component}/apis/config`
169176
* Alternatives, if applicable
170-
* `k8s.io/{component}/pkg/apis/config` (preferred)
177+
* `k8s.io/{component}/pkg/apis/config` (preferred, in the future)
171178
* `k8s.io/kubernetes/cmd/{component}/app/apis/config`
172179
* If dependencies allow it, we can move them to `k8s.io/{component}/pkg/apis/config/types.go`. Not having the external types there is intentional because the `pkg/` package tree is considered as "on-your-own-risks / no code compatibility guarantees", while `config/` is considered as a code API.
173180
* Internal scheme package: `k8s.io/kubernetes/pkg/{component}/apis/config/scheme/scheme.go`
174181
* The scheme package should expose `Scheme *runtime.Scheme`, `Codecs *serializer.CodecFactory`, and `AddToScheme(*runtime.Scheme)`, and have an `init()` method that runs `AddToScheme(Scheme)`
175182
* For the move to a staging repo to be possible, the external API package must not depend on the core repo.
176183
* Hence, all non-staging repo dependencies need to be removed/resolved before the package move.
177184
* Conversions from the external type to the internal type will be kept in `{internal_api_path}/{external_version}`, like for `k8s.io/api`
178-
* Defaulting code will be kept in this package, next to the conversions, if it already exists. We keep the decision about the destiny of defaulting open in this KEP.
185+
* Defaulting code will be kept in this package, besides the conversion functions.
186+
* The defaulting code here is specific for the usage of the component, and internal by design. If there are defaulting functions we
187+
feel would be generally useful, they might be exposed in `k8s.io/{component}/config/{version}/defaults.go` as `RecommendedDefaultFoo`
188+
functions that can be used by various consumers optionally.
189+
* Add at least some kind of minimum validation coverage for the types (e.g. ranges for integer values, URL scheme/hostname/port parsing,
190+
DNS name/label/domain validation) in the `{internal_api_path}/validation` package, targeting the internal API version. The consequence of
191+
these validations targeting the internal type is that they can't be exposed in the `k8s.io/{component}` repo, but publishing more
192+
functionality like that is out of scope for this KEP and left as a future task.
179193
* Create a "shared types"-package with structs generic to all or many componentconfig API groups, in the `k8s.io/apimachinery`, `k8s.io/apiserver` and `k8s.io/controller-manager` repos, depending on the struct.
180194
* Location: `k8s.io/{apimachinery,apiserver,controller-manager}/pkg/apis/config/{,v1alpha1}`
181-
* These aren’t "real" API groups, but have both internal and external versions
195+
* These aren’t "real" API groups, but they have both internal and external versions
182196
* Conversions and internal types are published to the staging repo.
183-
* Defaults are moved into the leaf groups using them as much as possible.
184-
* Remove the monolithic `componentconfig/v1alpha1` API group
197+
* Defaulting functions are of the `RecommendedDefaultFoo` format and opt-ins for consumers. No defaulting functions are registered in the scheme.
198+
* Remove the monolithic `componentconfig/v1alpha1` API group (`pkg/apis/componentconfig`)
185199
* Enable the staging bot to create the Github repos
186-
* We do not add further defaulting, but merely keep the minimum defaulting in-place to keep the current behaviour, but remove those defaulting funcs which are not used today.
200+
* Add API roundtrip (fuzzing), defaulting, conversion, JSON tag consistency and validation tests.
187201

188202
### Migration strategy per component or k8s.io repo
189203

@@ -192,7 +206,7 @@ types of the core components’ ComponentConfig in a top-level `config/` package
192206
* **Not a "real" API group, instead shared packages only with both external and internal types.**
193207
* **External Package with defaulting (where absolutely necessary) & conversions**: `k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go`
194208
* **Internal Package**: `k8s.io/apimachinery/pkg/apis/config/types.go`
195-
* Structs to be hosted:
209+
* Structs to be hosted initially:
196210
* ClientConnectionConfiguration
197211
* Assignee: @hanxiaoshuai
198212

@@ -201,9 +215,9 @@ types of the core components’ ComponentConfig in a top-level `config/` package
201215
* **Not a "real" API group, instead shared packages only with both external and internal types.**
202216
* **External Package with defaulting (where absolutely necessary) & conversions**: `k8s.io/apiserver/pkg/apis/config/v1alpha1/types.go`
203217
* **Internal Package**: `k8s.io/apiserver/pkg/apis/config/types.go`
204-
* Structs to be hosted:
205-
* LeaderElectionConfiguration
206-
* DebuggingConfiguration
218+
* Structs to be hosted initially:
219+
* `LeaderElectionConfiguration`
220+
* `DebuggingConfiguration`
207221
* later to be created: SecureServingConfiguration, AuthenticationConfiguration, AuthorizationConfiguration, etc.
208222
* Assignee: @hanxiaoshuai
209223

@@ -245,7 +259,7 @@ types of the core components’ ComponentConfig in a top-level `config/` package
245259
* **External Package with defaulting (where absolutely necessary) & conversions**: `k8s.io/controller-manager/pkg/apis/config/v1alpha1/types.go`
246260
* **Internal Package**: `k8s.io/controller-manager/pkg/apis/config/types.go`
247261
* Will host structs:
248-
* GenericComponentConfiguration (should be renamed to GenericControllerManagerConfiguration at the same time)
262+
* `GenericComponentConfiguration` (which will be renamed to `GenericControllerManagerConfiguration`)
249263
* Assignee: @stewart-yu
250264

251265
#### kube-controller-manager changes
@@ -304,13 +318,15 @@ Dep supports the import of sub-packages without inheriting dependencies from out
304318
Objective: Done for v1.12
305319

306320
Implementation order:
307-
* Start with the apiserver and apimachinery shared config repos, copy over the necessary structs as needed and create the external and internal API packages.
308-
* Start with the scheduler as the first component.
309-
* One PR for moving `KubeSchedulerConfiguration` to `staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go`, and the internal type to `pkg/scheduler/apis/config/types.go`.
310-
* Set up the conversion for the external type by creating the package `pkg/scheduler/apis/config/v1alpha1`, without `types.go`, like how `k8s.io/api` is set up.
311-
* This should be a pure code move.
321+
* Start with copying over the necessary structs to the `k8s.io/apiserver` and `k8s.io/apimachinery ` shared config packages, with external and internal API versions. The defaulting pattern for these types are of the `RecommendedDefaultFoo` form, in other words defaulting is not part of the scheme.
322+
* Remove as many unnecessary references to `pkg/apis/componentconfig` from the rest of the core repo as possible
323+
* Make the types in `pkg/apis/componentconfig` reuse the newly-created types in `k8s.io/apiserver` and `k8s.io/apimachinery `.
324+
* Start with the scheduler as the first component to be moved out.
325+
* One PR for moving `KubeSchedulerConfiguration` to `staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go`, and the internal type to `pkg/scheduler/apis/config/types.go`.
326+
* Set up the conversion for the external type by creating the package `pkg/scheduler/apis/config/v1alpha1`, without `types.go`, like how `k8s.io/api` is set up.
327+
* This should be a pure code move.
312328
* Set up staging publishing bot (async, non-critical)
313-
* The kubelet, kube-proxy and controller-manager follow, each one independently.
329+
* The kubelet, kube-proxy and kube-controller-manager types follow, each one independently.
314330

315331
### OWNERS files for new packages and repos
316332

0 commit comments

Comments
 (0)