This document describes the steps needed to perform in order to confidently add support for a new Kubernetes minor version.
⚠️ Typically, once a minor Kubernetes versionvX.Yis supported by Gardener, then all patch versionsvX.Y.Zare also automatically supported without any required action. This is because patch versions do not introduce any new feature or API changes, so there is nothing that needs to be adapted ingardener/gardenercode.
The Kubernetes community release a new minor version roughly every 4 months. Please refer to the official documentation about their release cycles for any additional information.
Shortly before a new release, an "umbrella" issue should be opened which is used to collect the required adaptations and to track the work items.
For example, #5102 can be used as a template for the issue description.
As you can see, the task of supporting a new Kubernetes version also includes the provider extensions maintained in the gardener GitHub organization and is not restricted to gardener/gardener only.
Generally, the work items can be split into two groups: The first group contains tasks specific to the changes in the given Kubernetes release, the second group contains Kubernetes release-independent tasks.
ℹ️ Upgrading the
k8s.io/*andsigs.k8s.io/controller-runtimeGolang dependencies is typically tracked and worked on separately (see e.g. #4772 or #5282).
Most new minor Kubernetes releases incorporate API changes, deprecations, or new features.
The community announces them via their change logs.
In order to derive the release-specific tasks, the respective change log for the new version vX.Y has to be read and understood (for example, the changelog for v1.24).
As already mentioned, typical changes to watch out for are:
- API version promotions or deprecations
- Feature gate promotions or deprecations
- CLI flag changes for Kubernetes components
- New default values in resources
- New available fields in resources
- New features potentially relevant for the Gardener system
- Changes of labels or annotations Gardener relies on
- ...
Obviously, this requires a certain experience and understanding of the Gardener project so that all "relevant changes" can be identified.
While reading the change log, add the tasks (along with the respective PR in kubernetes/kubernetes to the umbrella issue).
ℹ️ Some of the changes might be specific to certain cloud providers. Pay attention to those as well and add related tasks to the issue.
The following paragraphs describe recurring tasks that need to be performed for each new release.
The gardener/hyperkube repository is used to release container images consisting of the kubectl and kubelet binaries.
There is a CI/CD job that runs periodically and releases a new hyperkube image when there is a new Kubernetes release. Before proceeding with the next steps, make sure that a new hyperkube image is released for the corresponding new Kubernetes minor version. Make sure that container image is present in GCR.
- Allow instantiation of a Kubernetes client for the new minor version and update the
README.md: - Maintain the Kubernetes feature gates used for validation of
Shootresources:- The feature gates are maintained in this file.
- To maintain this list for new Kubernetes versions, run
hack/compare-k8s-feature-gates.sh <old-version> <new-version>(e.g.hack/compare-k8s-feature-gates.sh v1.26 v1.27). - It will present 3 lists of feature gates: those added and those removed in
<new-version>compared to<old-version>and feature gates that got locked to default in<new-version>. - Add all added feature gates to the map with
<new-version>asAddedInVersionand noRemovedInVersion. - For any removed feature gates, add
<new-version>asRemovedInVersionto the already existing feature gate in the map. - For feature gates locked to default, add
<new-version>asLockedToDefaultInVersionto the already existing feature gate in the map. - See this example commit.
- Maintain the Kubernetes
kube-apiserveradmission plugins used for validation ofShootresources:- The admission plugins are maintained in this file.
- To maintain this list for new Kubernetes versions, run
hack/compare-k8s-admission-plugins.sh <old-version> <new-version>(e.g.hack/compare-k8s-admission-plugins.sh 1.26 1.27). - It will present 2 lists of admission plugins: those added and those removed in
<new-version>compared to<old-version>. - Add all added admission plugins to the
admissionPluginsVersionRangesmap with<new-version>asAddedInVersionand noRemovedInVersion. - For any removed admission plugins, add
<new-version>asRemovedInVersionto the already existing admission plugin in the map. - Flag any admission plugins that are required (plugins that must not be disabled in the
Shootspec) by setting theRequiredboolean variable to true for the admission plugin in the map. - Flag any admission plugins that are forbidden by setting the
Forbiddenboolean variable to true for the admission plugin in the map.
- Maintain the Kubernetes
kube-apiserverAPI groups used for validation ofShootresources:- The API groups are maintained in this file.
- To maintain this list for new Kubernetes versions, run
hack/compare-k8s-api-groups.sh <old-version> <new-version>(e.g.hack/compare-k8s-api-groups.sh 1.26 1.27). - It will present 2 lists of API GroupVersions and 2 lists of API GroupVersionResources: those added and those removed in
<new-version>compared to<old-version>. - Add all added group versions to the
apiGroupVersionRangesmap and group version resources to theapiGVRVersionRangesmap with<new-version>asAddedInVersionand noRemovedInVersion. - For any removed APIs, add
<new-version>asRemovedInVersionto the already existing API in the corresponding map. - Flag any APIs that are required (APIs that must not be disabled in the
Shootspec) by setting theRequiredboolean variable to true for the API in theapiGVRVersionRangesmap. If this API also should not be disabled for Workerless Shoots, then setRequiredForWorkerlessboolean variable also to true. If the API is required for both Shoot types, then both of these booleans need to be set to true. If the whole API Group is required, then mark it correspondingly in theapiGroupVersionRangesmap.
- Maintain the Kubernetes
kube-controller-managercontrollers for each API group used in deploying required KCM controllers based on active APIs:- The API groups are maintained in this file.
- To maintain this list for new Kubernetes versions, run
hack/compute-k8s-controllers.sh <old-version> <new-version>(e.g.hack/compute-k8s-controllers.sh 1.26 1.27). - If it complains that the path for the controller is not present in the map, check the release branch of the new Kubernetes version and find the correct path for the missing/wrong controller. You can do so by checking the file
cmd/kube-controller-manager/app/controllermanager.goand where the controller is initialized from. As of now, there is no straight-forward way to map each controller to its file. If this has improved, please enhance the script. - If the paths are correct, it will present 2 lists of controllers: those added and those removed for each API group in
<new-version>compared to<old-version>. - Add all added controllers to the
APIGroupControllerMapmap and under the corresponding API group with<new-version>asAddedInVersionand noRemovedInVersion. - For any removed controllers, add
<new-version>asRemovedInVersionto the already existing controller in the corresponding API group map. - Make sure that the API groups in this file are in sync with the groups in this file. For example,
core/v1is replaced by the script asv1andapiserverinternalasinternal. This is because the API groups registered by the apiserver (example) and the file path imported by the controllers (example) might be slightly different in some cases.
- Maintain the
ServiceAccountnames for the controllers part ofkube-controller-manager:- The names are maintained in this file.
- To maintain this list for new Kubernetes versions, run
hack/compare-k8s-controllers.sh <old-version> <new-version>(e.g.hack/compare-k8s-controllers.sh 1.26 1.27). - It will present 2 lists of controllers: those added and those removed in
<new-version>compared to<old-version>. - Double check whether such
ServiceAccountindeed appears in thekube-systemnamespace when creating a cluster with<new-version>. Note that it sometimes might be hidden behind a default-off feature gate. You can create a local cluster with the new version using the local provider. - If it appears, add all added controllers to the list based on the Kubernetes version (example).
- For any removed controllers, add them only to the Kubernetes version if it is low enough.
- Maintain the names of controllers used for workerless Shoots, here after carefully evaluating whether they are needed if there are no workers.
- Maintain copies of the
DaemonSetcontroller's scheduling logic:gardener-resource-manager'sNodecontroller uses a copy of parts of theDaemonSetcontroller's logic for determining whether a specificNodeshould run a daemon pod of a givenDaemonSet: see this file.- Check the referenced upstream files for changes to the
DaemonSetcontroller's logic and adapt our copies accordingly. This might include introducing version-specific checks in our codebase to handle different shoot cluster versions.
- Maintain version specific defaulting logic in shoot admission plugin:
- Sometimes default values for shoots are intentionally changed with the introduction of a new Kubernetes version.
- The final Kubernetes version for a shoot is determined in the Shoot Validator Admission Plugin.
- Any defaulting logic that depends on the version should be placed in this admission plugin (example).
- Ensure that maintenance-controller is able to auto-update shoots to the new Kubernetes version. Changes to the shoot spec required for the Kubernetes update should be enforced in such cases (examples).
- Bump the used Kubernetes version for local e2e test.
- See this example commit.
Work on all the tasks you have collected and validate them using the local provider. Execute the e2e tests and if everything looks good, then go ahead and file the PR (example PR). Generally, it is great if you add the PRs also to the umbrella issue so that they can be tracked more easily.
After the PR in gardener/gardener for the support of the new version has been merged, you can go ahead and work on the provider extensions.
Actually, you can already start even if the PR is not yet merged and use the branch of your fork.
- Update the
github.com/gardener/gardenerdependency in the extension and update theREADME.md. - Work on release-specific tasks related to this provider.
Some of the cloud providers are not yet using upstream cloud-controller-manager images.
Instead, we build and maintain them ourselves:
Until we switch to upstream images, you need to update the Kubernetes dependencies and release a new image. The required steps are as follows:
- Checkout the
legacy-cloud-providerbranch of the respective repository - Bump the versions in the
Dockerfile(example commit). - Update the
VERSIONtovX.Y.Z-devwhereZis the latest available Kubernetes patch version for thevX.Yminor version. - Update the
k8s.io/*dependencies in thego.modfile tovX.Y.Zand rungo mod tidy(example commit). - Checkout a new
release-vX.Ybranch and release it (example)
As you are already on it, it is great if you also bump the
k8s.io/*dependencies for the last three minor releases as well. In this case, you need to checkout therelease-vX.{Y-{1,2,3}}branches and only perform the last three steps (example branch, example commit).
Now you need to update the new releases in the charts/images.yaml of the respective provider extension so that they are used (see this example commit for reference).
Again, work on all the tasks you have collected. This time, you cannot use the local provider for validation but should create real clusters on the various infrastructures. Typically, the following validations should be performed:
- Create new clusters with versions <
vX.Y - Create new clusters with version =
vX.Y - Upgrade old clusters from version
vX.{Y-1}to versionvX.Y - Delete clusters with versions <
vX.Y - Delete clusters with version =
vX.Y
If everything looks good, then go ahead and file the PR (example PR). Generally, it is again great if you add the PRs also to the umbrella issue so that they can be tracked more easily.