|
| 1 | +--- |
| 2 | +layout: blog |
| 3 | +title: "Kubernetes API and Feature Removals In 1.22: Here’s What You Need To Know" |
| 4 | +date: 2021-07-14 |
| 5 | +slug: upcoming-changes-in-kubernetes-1-22 |
| 6 | +--- |
| 7 | + |
| 8 | +**Authors**: Krishna Kilari (Amazon Web Services), Tim Bannister (The Scale Factory) |
| 9 | + |
| 10 | +As the Kubernetes API evolves, APIs are periodically reorganized or upgraded. |
| 11 | +When APIs evolve, the old APIs they replace are deprecated, and eventually removed. |
| 12 | +See [Kubernetes API removals](#kubernetes-api-removals) to read more about Kubernetes' |
| 13 | +policy on removing APIs. |
| 14 | + |
| 15 | +We want to make sure you're aware of some upcoming removals. These are |
| 16 | +beta APIs that you can use in current, supported Kubernetes versions, |
| 17 | +and they are already deprecated. The reason for all of these removals |
| 18 | +is that they have been superseded by a newer, stable (“GA”) API. |
| 19 | + |
| 20 | +Kubernetes 1.22, due for release in August 2021, will remove a number of deprecated |
| 21 | +APIs. |
| 22 | +[Kubernetes 1.22 Release Information](https://www.kubernetes.dev/resources/release/) |
| 23 | +has details on the schedule for the v1.22 release. |
| 24 | + |
| 25 | +## API removals for Kubernetes v1.22 {#api-changes} |
| 26 | + |
| 27 | +The **v1.22** release will stop serving the API versions we've listed immediately below. |
| 28 | +These are all beta APIs that were previously deprecated in favor of newer and more stable |
| 29 | +API versions. |
| 30 | +<!-- sorted by API group --> |
| 31 | + |
| 32 | +* Beta versions of the `ValidatingWebhookConfiguration` and `MutatingWebhookConfiguration` API (the **admissionregistration.k8s.io/v1beta1** API versions) |
| 33 | +* The beta `CustomResourceDefinition` API (**apiextensions.k8s.io/v1beta1**) |
| 34 | +* The beta `APIService` API (**apiregistration.k8s.io/v1beta1**) |
| 35 | +* The beta `TokenReview` API (**authentication.k8s.io/v1beta1**) |
| 36 | +* Beta API versions of `SubjectAccessReview`, `LocalSubjectAccessReview`, `SelfSubjectAccessReview` (API versions from **authorization.k8s.io/v1beta1**) |
| 37 | +* The beta `CertificateSigningRequest` API (**certificates.k8s.io/v1beta1**) |
| 38 | +* The beta `Lease` API (**coordination.k8s.io/v1beta1**) |
| 39 | +* All beta `Ingress` APIs (the **extensions/v1beta1** and **networking.k8s.io/v1beta1** API versions) |
| 40 | + |
| 41 | + |
| 42 | +## What to do |
| 43 | + |
| 44 | +We're going to run through each of the resources that are affected by these removals |
| 45 | +and explain the steps you'll need to take. |
| 46 | + |
| 47 | +`Ingress` |
| 48 | +: Migrate to use the **networking.k8s.io/v1** |
| 49 | + [Ingress](/docs/reference/kubernetes-api/service-resources/ingress-v1/) API, |
| 50 | + [available since v1.19](/blog/2020/08/26/kubernetes-release-1.19-accentuate-the-paw-sitive/#ingress-graduates-to-general-availability). |
| 51 | + The related API [IngressClass](/docs/reference/kubernetes-api/service-resources/ingress-class-v1/) |
| 52 | + is designed to complement the [Ingress](/docs/concepts/services-networking/ingress/) |
| 53 | + concept, allowing you to configure multiple kinds of Ingress within one cluster. |
| 54 | + If you're currently using the deprecated |
| 55 | + [`kubernetes.io/ingress.class`](https://kubernetes.io/docs/reference/labels-annotations-taints/#kubernetes-io-ingress-class-deprecated) |
| 56 | + annotation, plan to switch to using the `.spec.ingressClassName` field instead. |
| 57 | + On any cluster running Kubernetes v1.19 or later, you can use the v1 API to |
| 58 | + retrieve or update existing Ingress objects, even if they were created using an |
| 59 | + older API version. |
| 60 | + |
| 61 | + When you convert an Ingress to the v1 API, you should review each rule in that Ingress. |
| 62 | + Older Ingresses use the legacy `ImplementationSpecific` path type. Instead of `ImplementationSpecific`, switch [path matching](/docs/concepts/services-networking/ingress/#path-types) to either `Prefix` or `Exact`. One of the benefits of moving to these alternative path types is that it becomes easier to migrate between different Ingress classes. |
| 63 | + |
| 64 | + **ⓘ** As well as upgrading _your_ own use of the Ingress API as a client, make sure that |
| 65 | + every ingress controller that you use is compatible with the v1 Ingress API. |
| 66 | + Read [Ingress Prerequisites](/docs/concepts/services-networking/ingress/#prerequisites) |
| 67 | + for more context about Ingress and ingress controllers. |
| 68 | + |
| 69 | +`ValidatingWebhookConfiguration` and `MutatingWebhookConfiguration` |
| 70 | +: Migrate to use the **admissionregistration.k8s.io/v1** API versions of |
| 71 | + [ValidatingWebhookConfiguration](/docs/reference/kubernetes-api/extend-resources/validating-webhook-configuration-v1/) |
| 72 | + and [MutatingWebhookConfiguration](/docs/reference/kubernetes-api/extend-resources/mutating-webhook-configuration-v1/), |
| 73 | + available since v1.16. |
| 74 | + You can use the v1 API to retrieve or update existing objects, even if they were created using an older API version. |
| 75 | + |
| 76 | +`CustomResourceDefinition` |
| 77 | +: Migrate to use the [CustomResourceDefinition](/docs/reference/kubernetes-api/extend-resources/custom-resource-definition-v1/) |
| 78 | + **apiextensions.k8s.io/v1** API, available since v1.16. |
| 79 | + You can use the v1 API to retrieve or update existing objects, even if they were created |
| 80 | + using an older API version. If you defined any custom resources in your cluster, those |
| 81 | + are still served after you upgrade. |
| 82 | + |
| 83 | + If you're using external CustomResourceDefinitions, you can use |
| 84 | + [`kubectl convert`](#kubectl-convert) to translate existing manifests to use the newer API. |
| 85 | + Because there are some functional differences between beta and stable CustomResourceDefinitions, |
| 86 | + our advice is to test out each one to make sure it works how you expect after the upgrade. |
| 87 | + |
| 88 | +`APIService` |
| 89 | +: Migrate to use the **apiregistration.k8s.io/v1** [APIService](/docs/reference/kubernetes-api/cluster-resources/api-service-v1/) |
| 90 | + API, available since v1.10. |
| 91 | + You can use the v1 API to retrieve or update existing objects, even if they were created using an older API version. |
| 92 | + If you already have API aggregation using an APIService object, this aggregation continues |
| 93 | + to work after you upgrade. |
| 94 | + |
| 95 | +`TokenReview` |
| 96 | +: Migrate to use the **authentication.k8s.io/v1** [TokenReview](/docs/reference/kubernetes-api/authentication-resources/token-review-v1/) |
| 97 | + API, available since v1.10. |
| 98 | + |
| 99 | + In Kubernetes version v1.21 and earlier, the Kubernetes API server |
| 100 | + [defaults](/docs/reference/access-authn-authz/authentication/#webhook-token-authentication) |
| 101 | + to sending _beta_ TokenReviews to webhooks. See [Rehearse for the upgrade](#rehearse-for-the-upgrade) |
| 102 | + for some specific tips about switching to the stable API. |
| 103 | + |
| 104 | +`SubjectAccessReview`, `SelfSubjectAccessReview` and `LocalSubjectAccessReview` |
| 105 | +: Migrate to use the **authorization.k8s.io/v1** versions of those |
| 106 | + [authorization APIs](/docs/reference/kubernetes-api/authorization-resources/), available since v1.6. |
| 107 | + |
| 108 | +`CertificateSigningRequest` |
| 109 | +: Migrate to use the **certificates.k8s.io/v1** |
| 110 | + [CertificateSigningRequest](/docs/reference/kubernetes-api/authentication-resources/certificate-signing-request-v1/) |
| 111 | + API, available since v1.19. |
| 112 | + You can use the v1 API to retrieve or update existing objects, even if they were created |
| 113 | + using an older API version. Existing issued certificates retain their validity when you upgrade. |
| 114 | + |
| 115 | +`Lease` |
| 116 | +: Migrate to use the **coordination.k8s.io/v1** [Lease](/docs/reference/kubernetes-api/cluster-resources/lease-v1/) |
| 117 | + API, available since v1.14. |
| 118 | + You can use the v1 API to retrieve or update existing objects, even if they were created |
| 119 | + using an older API version. |
| 120 | + |
| 121 | +### `kubectl convert` |
| 122 | + |
| 123 | +There is a plugin to `kubectl` that provides the `kubectl convert` subcommand. |
| 124 | +It's an official plugin that you can download as part of Kubernetes. |
| 125 | +See [Download Kubernetes](/releases/download/) for more details. |
| 126 | + |
| 127 | +You can use `kubectl convert` to update manifest files to use a different API |
| 128 | +version. For example, if you have a manifest in source control that uses the beta |
| 129 | +Ingress API, you can check that definition out, |
| 130 | +and run |
| 131 | +`kubectl convert -f <manifest> --output-version <group>/<version>`. |
| 132 | +You can use the `kubectl convert` command to automatically convert an |
| 133 | +existing manifest. |
| 134 | + |
| 135 | +For example, to convert an older Ingress definition to |
| 136 | +`networking.k8s.io/v1`, you can run: |
| 137 | +```bash |
| 138 | +kubectl convert -f ./legacy-ingress.yaml --output-version networking.k8s.io/v1 |
| 139 | +``` |
| 140 | + |
| 141 | +The automatic conversion uses a similar technique to how the Kubernetes control plane |
| 142 | +updates objects that were originally created using an older API version. Because it's |
| 143 | +a mechanical conversion, you might need to go in and change the manifest to adjust |
| 144 | +defaults etc. |
| 145 | + |
| 146 | +### Rehearse for the upgrade |
| 147 | + |
| 148 | +If you manage your cluster's API server component, you can try out these API |
| 149 | +removals before you upgrade to Kubernetes v1.22. |
| 150 | + |
| 151 | +To do that, add the following to the kube-apiserver command line arguments: |
| 152 | + |
| 153 | +`--runtime-config=admissionregistration.k8s.io/v1beta1=false,apiextensions.k8s.io/v1beta1=false,apiregistration.k8s.io/v1beta1=false,authentication.k8s.io/v1beta1=false,authorization.k9s.io/v1=false,certificates.k8s.io/v1beta=false,coordination.k8s.io/v1beta1=false,extensions/v1beta1/ingresses=false,networking.k8s.io/v1beta1/ingresses=false,networking.k8s.io/v1beta1/ingressclasses=false` |
| 154 | + |
| 155 | +Once you've switched all the kube-apiservers in your cluster to use that setting, |
| 156 | +those beta APIs are removed. You can test that API clients (`kubectl`, deployment |
| 157 | +tools, custom controllers etc) still work how you expect, and you can revert if |
| 158 | +you need to without having to plan a more disruptive downgrade. |
| 159 | + |
| 160 | + |
| 161 | +There's another setting that's relevant if you use webhook authentication checks. |
| 162 | +Kubernetes v1.22 is the first version of Kubernetes that sends TokenReview objects |
| 163 | +to webhooks using the `authentication.k8s.io/v1` API by default. However, you can |
| 164 | +switch over earlier to try it out. |
| 165 | +Add `--authentication-token-webhook-version=v1` to the command line options for |
| 166 | +the kube-apiserver, and check that webhooks for authentication still work how you |
| 167 | +expected. |
| 168 | + |
| 169 | +Once you're happy it works, you can leave the `--authentication-token-webhook-version=v1` |
| 170 | +option set through and after the upgrade to v1.22. |
| 171 | + |
| 172 | +### Advice for software authors |
| 173 | + |
| 174 | +Maybe you're reading this because you're a developer of an addon or other |
| 175 | +component that integrates with Kubernetes? |
| 176 | + |
| 177 | +If you develop an Ingress controller, webhook authenticator, an API aggregation, or |
| 178 | +any other tool that relies on these deprecated APIs, you should already have started |
| 179 | +to switch your software over. |
| 180 | + |
| 181 | +You can use the tips in |
| 182 | +[Rehearse for the upgrade](#rehearse-for-the-upgrade) to run your own Kubernetes |
| 183 | +cluster that only uses the new APIs, and make sure that your code works OK. |
| 184 | +For your documentation, make sure readers are aware of any steps they should take |
| 185 | +for the Kubernetes v1.22 upgrade. |
| 186 | + |
| 187 | +Where possible, give your users a hand to adopt the new APIs early - perhaps in a |
| 188 | +test environment - so they can give you feedback about any problems. |
| 189 | + |
| 190 | +There are some [more deprecations](#looking-ahead) coming in Kubernetes v1.25, |
| 191 | +so plan to have those covered too. |
| 192 | + |
| 193 | +## Kubernetes API removals |
| 194 | + |
| 195 | +Here's some background about why Kubernetes removes some APIs, and also a promise |
| 196 | +about _stable_ APIs in Kubernetes. |
| 197 | + |
| 198 | +Kubernetes follows a defined |
| 199 | +[deprecation policy](/docs/reference/using-api/deprecation-policy/) for its |
| 200 | +features, including the Kubernetes API. That policy allows for replacing stable |
| 201 | +(“GA”) APIs from Kubernetes. Importantly, this policy means that a stable API only |
| 202 | +be deprecated when a newer stable version of that same API is available. |
| 203 | + |
| 204 | +That stability guarantee matters: if you're using a stable Kubernetes API, there |
| 205 | +won't ever be a new version released that forces you to switch to an alpha or beta |
| 206 | +feature. |
| 207 | + |
| 208 | +Earlier stages are different. Alpha features are under test and potentially |
| 209 | +incomplete. Almost always, alpha features are disabled by default. |
| 210 | +Kubernetes releases can and do remove alpha features that haven't worked out. |
| 211 | + |
| 212 | +After alpha, comes beta. These features are typically enabled by default; if the |
| 213 | +testing works out, the feature can graduate to stable. If not, it might need |
| 214 | +a redesign. |
| 215 | + |
| 216 | +Last year, Kubernetes officially |
| 217 | +[adopted](/blog/2020/08/21/moving-forward-from-beta/#avoiding-permanent-beta) |
| 218 | +a policy for APIs that have reached their beta phase: |
| 219 | + |
| 220 | +> For Kubernetes REST APIs, when a new feature's API reaches beta, that starts |
| 221 | +> a countdown. The beta-quality API now has three releases … |
| 222 | +> to either: |
| 223 | +> |
| 224 | +> * reach GA, and deprecate the beta, or |
| 225 | +> * have a new beta version (and deprecate the previous beta). |
| 226 | +
|
| 227 | +_At the time of that article, three Kubernetes releases equated to roughly nine |
| 228 | +calendar months. Later that same month, Kubernetes |
| 229 | +adopted a new |
| 230 | +release cadence of three releases per calendar year, so the countdown period is |
| 231 | +now roughly twelve calendar months._ |
| 232 | + |
| 233 | +Whether an API removal is because of a beta feature graduating to stable, or |
| 234 | +because that API hasn't proved successful, Kubernetes will continue to remove |
| 235 | +APIs by following its deprecation policy and making sure that migration options |
| 236 | +are documented. |
| 237 | + |
| 238 | +### Looking ahead |
| 239 | + |
| 240 | +The upcoming **v1.25** release will stop serving beta versions of several Kubernetes APIs |
| 241 | +that have been stable for some time. The same release **removes** PodSecurityPolicy, |
| 242 | +which is deprecated and won't graduate to stable. See |
| 243 | +[PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/) |
| 244 | +for more information. |
| 245 | + |
| 246 | +The official [list of API removals](/docs/reference/using-api/deprecation-guide/#v1-25) |
| 247 | +planned for Kubernetes 1.25 is: |
| 248 | + |
| 249 | +* The beta `CronJob` API (**batch/v1beta1**) |
| 250 | +* The beta `EndpointSlice` API (**networking.k8s.io/v1beta1**) |
| 251 | +* The beta `PodDisruptionBudget` API (**policy/v1beta1**) |
| 252 | +* The beta `PodSecurityPolicy` API (**policy/v1beta1**) |
| 253 | + |
| 254 | +## Want to know more? |
| 255 | + |
| 256 | +Deprecations are announced in the Kubernetes release notes. You can see the announcements |
| 257 | +of pending deprecations in the release notes for |
| 258 | +[1.19](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.19.md#deprecations), |
| 259 | +[1.20](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.20.md#deprecation), |
| 260 | +and [1.21](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.21.md#deprecation). |
| 261 | + |
| 262 | +For information on the process of deprecation and removal, check out the official Kubernetes |
| 263 | +[deprecation policy](/docs/reference/using-api/deprecation-policy/#deprecating-parts-of-the-api) |
| 264 | +document. |
0 commit comments