sigs.k8s.io/cluster-api@v1.7.1/docs/proposals/20210210-insulate-users-from-kubeadm-API-changes.md (about) 1 --- 2 title: Insulate users from kubeadm API version changes 3 authors: 4 - "@fabriziopandini" 5 reviewers: 6 - "@vincepri" 7 creation-date: 2021-02-10 8 last-updated: 2021-02-10 9 status: implementable 10 see-also: 11 - "/docs/proposals/20190610-machine-states-preboot-bootstrapping.md" 12 replaces: 13 superseded-by: 14 --- 15 16 # Insulate users from kubeadm API version changes 17 18 ## Table of Contents 19 20 <!-- START doctoc generated TOC please keep comment here to allow auto update --> 21 <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> 22 23 - [Glossary](#glossary) 24 - [Summary](#summary) 25 - [Motivation](#motivation) 26 - [Goals](#goals) 27 - [Non-Goals](#non-goals) 28 - [Future work](#future-work) 29 - [Proposal](#proposal) 30 - [User Stories](#user-stories) 31 - [Story 1](#story-1) 32 - [Story 2](#story-2) 33 - [Requirements](#requirements) 34 - [Implementation Details/Notes/Constraints](#implementation-detailsnotesconstraints) 35 - [Background info about kubeadm API version](#background-info-about-kubeadm-api-version) 36 - [Background info about kubeadm types into the KubeadmConfig/KubeadmControlPlane specs](#background-info-about-kubeadm-types-into-the-kubeadmconfigkubeadmcontrolplane-specs) 37 - [Cluster API v1alpha3 changes](#cluster-api-v1alpha3-changes) 38 - [Cluster API v1alpha4 changes](#cluster-api-v1alpha4-changes) 39 - [Security Model](#security-model) 40 - [Risks and Mitigations](#risks-and-mitigations) 41 - [Alternatives](#alternatives) 42 - [Upgrade Strategy](#upgrade-strategy) 43 - [Additional Details](#additional-details) 44 - [Test Plan](#test-plan) 45 - [Implementation History](#implementation-history) 46 47 <!-- END doctoc generated TOC please keep comment here to allow auto update --> 48 49 ## Glossary 50 51 Refer to the [Cluster API Book Glossary](https://cluster-api.sigs.k8s.io/reference/glossary.html). 52 53 ## Summary 54 55 Make CABPK and KCP to use more recent versions of the kubeadm API and insulate users from 56 kubeadm API version changes. 57 58 ## Motivation 59 60 Cluster bootstrap provider for kubeadm (CABPK) and the control plane provider for kubeadm 61 (KCP) API still relying on kubeadm v1beta1 API, which has been deprecated, and it is going 62 to be removed ASAP. 63 64 While moving to a more recent version of the kubeadm API is a required move, Cluster API 65 should take this opportunity to stop relying on the assumption that the kubeadm API types in the 66 KubeadmConfig/KubeadmControlPlane specs are supported(1) by all the Kubernetes/kubeadm version 67 in the support range. 68 69 This would allow to separate what users fill in the KubeadmConfig/KubeadmControlPlane 70 from which kubeadm API version Cluster API end up using in the bootstrap data. 71 72 (1) Supported in this context means that the serialization format of the types is the same, 73 because types are already different (see background info in the implementation details paragraph). 74 75 ### Goals 76 77 - Define a stop-gap for using the most recent version of the kubeadm API in Cluster API 78 v1alpha3 - introducing any breaking changes. 79 - Define how to stop to exposing the kubeadm v1betax types in the KubeadmConfig/KubeadmControlPlane 80 specs for v1alpha4. 81 - Define how to use the right version of the kubeadm types generating our kubeadm yaml 82 file and when interacting with the kubeadm-config ConfigMap. 83 - Ensure a clean and smooth v1alpha3 to v1alpha4 upgrade experience. 84 85 ### Non-Goals 86 87 - Adding or removing fields in KubeadmConfig/KubeadmControlPlane spec. 88 - Introduce behavioral changes in CABPK or KCP. 89 90 ### Future work 91 92 - Evaluate improvements for the Cluster API owned version of KubeadmConfig/KubeadmControlPlane 93 specs types. 94 - Make it possible for the Cluster API users to take benefit of changes introduced 95 in recent versions of the Kubeadm API. 96 97 ## Proposal 98 99 ### User Stories 100 101 #### Story 1 102 103 As a user, I want to user kubeadm providers for Cluster API (CABPK & KPC) in the same 104 way across the entire spectrum of supported kubernetes versions. 105 106 #### Story 2 107 108 As the kubeadm tool, I want the kubeadm providers for Cluster API (CABPK & KPC) to 109 use the latest kubeadm API supported by the target kubeadm/kubernetes version. 110 111 ### Requirements 112 113 R1 - avoid breaking changes in v1alpha3 114 R2 - ensure a clean v1alpha3 to v1alpha4 upgrade 115 116 ### Implementation Details/Notes/Constraints 117 118 #### Background info about kubeadm API version 119 120 kubeadm v1beta1 types: 121 122 - Introduced in v1.13. 123 - Deprecation cycle started with v1.17. 124 - Removal scheduled for v1.20 but then postponed to v1.21. 125 126 kubeadm v1beta2 types: 127 128 - Introduced in v1.15. 129 - Changes from the previous version are minimal: 130 - Support for IgnorePreflightErrors into the NodeRegistrationOptions. 131 - Support for CertificateKey into InitConfiguration and JoinConfiguration 132 configuration (not relevant for Cluster API because it is not using the 133 automatic certificate copy feature). 134 - improved serialization support (in practice a set of `omitempty` fixes). 135 136 #### Background info about kubeadm types into the KubeadmConfig/KubeadmControlPlane specs 137 138 Given the fact that importing kubeadm (which is part of the Kubernetes codebase) 139 in Cluster API is impractical, Cluster API hosts a mirror of kubeadm API types. 140 141 kubeadm v1beta1 mirror-types: 142 143 - Hosted in `bootstrap/kubeadm/types/upstreamv1beta1`. 144 - Diverged from the original v1beta1 types for better CRD support (in practice 145 a set of `+optional` fixes, few `omitempty` differences). 146 147 kubeadm v1beta2 mirror-types: 148 149 - Hosted in `bootstrap/kubeadm/types/upstreamv1beta2`. 150 - Currently, not used in the Cluster API codebase. 151 - Does not include changes for better CRD support introduced in kubeadm v1beta1 152 mirror-types. 153 154 #### Cluster API v1alpha3 changes 155 156 Changes to cluster API v1alpha3 release should be minimal and no breaking change 157 should be introduced while implementing this proposal. 158 159 According to this principle and to the feedback to this proposal, 160 we are going to implement alternative 2 described below. 161 162 __Alternative 1:__ 163 164 Keep kubeadm v1beta1 types as a Hub type (1); implement conversion to kubeadm API 165 version f(Kubernetes Version) when generating the kubeadm config for init/join ( 166 e.g convert to kubeadm API v1beta2 for Kubernetes version >= v1.15, convert to 167 kubeadm API v1beta1 for Kubernetes version < v1.15). 168 169 This alternative is the more clean, robust and forward looking, but it requires 170 much more work than alternative 2. 171 172 __Alternative 2:__ 173 174 Keep kubeadm v1beta1 types as a Hub type (1); only change the apiVersion to 175 `kubeadm.k8s.io/v1beta2` in the generated kubeadm config for init/join. 176 177 This alternative is based on following considerations: 178 179 - kubeadm v1beta1 mirror types are "compatible" with kubeadm v1beta2 types 180 - Having support for IgnorePreflightErrors into the NodeRegistrationOptions 181 is not required for Cluster API v1alpha3 182 - The automatic certificate copy feature is not used by Cluster API 183 - Improved serialization support has been already applied to the kubeadm 184 v1beta1 mirror-types (and further extended). 185 - the minimal Kubernetes version supported by Cluster API is v1.16, and kubeadm 186 v1.16 could work with v1beta2 types. Same for all the other versions up to latest(1.20) 187 and next (1.21). 188 - limitations: this approach is not future proof, and it should be reconsidered 189 whenever a new version of kubeadm types is created while v1alpha3 is still supported. 190 191 __Common considerations for both alternatives__ 192 193 KCP is modifying the kubeadm-config Config Map generated by kubeadm, and ideally also 194 this bit of code should be made kubeadm version aware. 195 196 However, given that the current implementation currently uses unstructured, and 197 a change for using the kubeadm types, requires a big refactor, the proposed approach 198 for v1alpha3 is to limit the changes to only upgrade the apiVersion when required. 199 200 - limitations: this approach is not future proof, and it should be reconsidered 201 whenever a new version of kubeadm types is changing one of the fields 202 edited during upgrades. 203 204 (1) See https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts.html 205 for a definition of Hub or spoke types/version. 206 207 #### Cluster API v1alpha4 changes 208 209 Changes to cluster API v1alpha4 could be more invasive and seek for a 210 forward-looking solution. 211 212 Planned actions are: 213 214 - introduce a Cluster API owned version of the kubeadm config types 215 (starting from kubeadm v1beta1) to be used by KubeadmConfig/KubeadmControlPlane 216 specs; this should also act as a serialization/deserialization hub (1). 217 Please note that those types will be part of Cluster API types, and thus initially 218 versioned as v1alpha4; once conversion will be in place, those types are not required 219 anymore to have the same serialization format of the real kubeadm types. 220 - preserve `bootstrap/kubeadm/types/upstreamv1beta1` as a serialization/deserialization 221 spoke (1)(2) for v1alpha4 (also, this will be used by v1alpha3 API types until removal) 222 - preserve `bootstrap/kubeadm/types/upstreamv1beta2` as serialization/deserialization 223 spoke (1)(2) for v1alpha4 224 - implement hub/spoke conversions (1) 225 - make CABPK to use conversion while generating the kubeadm config file for init/join 226 - make KCP to use conversion while serializing/deserializing the kubeadm-config Config Map 227 - make KCP to use the Cluster API owned version of the kubeadm config types instead 228 of using `Unstructured` for the kubeadm-config Config Map handling 229 - add the `IgnorePreflightError` field to the Cluster API owned types; this field will be silently 230 ignored when converting to v1beta1 (because this version does not support this field). 231 Note: we are not planning to add `CertificateKey` to the Cluster API owned types because 232 this field is not relevant for Cluster API. 233 234 (1) See https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts.html 235 for a definition of Hub or spoke types/version. 236 (2) As soon as it will be possible to vendor kubeadm types, we should drop this copy 237 and use kubeadm library as a source of truth. Hover there is no concrete plan for this yet. 238 239 ### Security Model 240 241 This proposal does not introduce changes the existing security model. 242 243 ### Risks and Mitigations 244 245 - Time crunch 246 247 This change has been postponed several times for different reasons, 248 and now it is being worked with a strict deadline before kubeadm type removal. 249 Mitigation: Changes to the KubeadmConfig/KubeadmControlPlane specs types considered 250 as a future work. 251 252 ## Alternatives 253 254 The `Alternatives` section is used to highlight and record other possible approaches 255 to delivering the value proposed by a proposal. 256 257 ## Upgrade Strategy 258 259 Given the requirement to provide a clean upgrade path from v1alpha3 to v1alpha4, 260 upgrades should be handles using conversion web-hooks only. 261 No external upgrade tool/additional manual steps should be required for upgrade. 262 263 ## Additional Details 264 265 ### Test Plan 266 267 For v1alpha4 this will be tested by the periodic jobs testing 268 creating cluster with different Kubernetes releases, doing upgrades to the next version 269 and running Kubernetes conformance. 270 271 For v1alpha3 there are no such jobs. We should explore if to backport all the 272 required changes to the test framework (complex) or if to create ad-hoc test for this 273 using what is supported by the v1alpha3 version of the test framework (possible limitations). 274 275 ## Implementation History 276 277 - 2021-02-10: First draft and round of feedback from community