|
1 | 1 | # Upgrading kubernetes
|
2 | 2 |
|
| 3 | +## **NOTE for Kubernetes >1.31** |
| 4 | + |
| 5 | +Kops' upgrade procedure has historically risked violating the [Kubelet version skew policy](https://kubernetes.io/releases/version-skew-policy/#kubelet). After `kops update cluster --yes` completes and before every kube-apiserver is replaced with `kops rolling-update cluster --yes`, newly launched nodes running newer kubelet versions could be connecting to older `kube-apiserver` nodes. |
| 6 | + |
| 7 | +**Violating this policy when upgrading to Kubernetes 1.31 can cause newer kubelets to crash.** [This kubernetes issue](https://github.com/kubernetes/kubernetes/issues/127316) provides details though it was not addressed because the change does not actually violate the version skew policy, it merely breaks tooling that was already violating the policy. |
| 8 | + |
| 9 | +To upgrade a cluster to Kubernetes 1.31 or newer, use the new `kops reconcile cluster` command introduced in Kops 1.31. This replaces both `kops update cluster --yes` and `kops rolling-update cluster --yes`. |
| 10 | + |
| 11 | +`kops reconcile cluster` will interleave the cloud provider updates of `kops update cluster --yes` with the node rotations of `kops rolling-update cluster --yes`. |
| 12 | + |
| 13 | +It is comparable to the following sequence: |
| 14 | +1. `kops update cluster --instance-group-roles=control-plane,apiserver --yes` |
| 15 | +2. `kops rolling-update cluster --instance-group-roles=control-plane,apiserver --yes` |
| 16 | +3. `kops update cluster --yes` |
| 17 | +4. `kops rolling-update cluster --yes` |
| 18 | +5. `kops update cluster --prune --yes` |
| 19 | + |
| 20 | +**Terraform** users will need to use a targeted terraform apply with the normal `kops rolling-update cluster --yes`: |
| 21 | + |
| 22 | +```sh |
| 23 | +$ kops update cluster --target terraform ... |
| 24 | + |
| 25 | +# Get the terraform resource IDs of the instance groups with a spec.role of `ControlPlane`, `Master`, or `APIServer` |
| 26 | +# The exact output may vary. |
| 27 | +$ terraform state list | grep -E 'aws_autoscaling_group|google_compute_instance_group_manager|hcloud_server|digitalocean_droplet|scaleway_instance_server' |
| 28 | +aws_autoscaling_group.controlplane-us-east-1a-example-com |
| 29 | +aws_autoscaling_group.controlplane-us-east-1b-example-com |
| 30 | +aws_autoscaling_group.controlplane-us-east-1c-example-com |
| 31 | +aws_autoscaling_group.nodes-example-com |
| 32 | +aws_autoscaling_group.bastion-example-com |
| 33 | + |
| 34 | +# Apply the changes to all control plane instance groups |
| 35 | +$ terraform apply -target 'aws_autoscaling_group.controlplane-us-east-1a-example-com' -target 'aws_autoscaling_group.controlplane-us-east-1b-example-com' -target 'aws_autoscaling_group.controlplane-us-east-1c-example-com' |
| 36 | + |
| 37 | +# Roll the apiserver nodes |
| 38 | +$ kops rolling-update cluster --yes --instance-group-roles control-plane,apiserver |
| 39 | + |
| 40 | +# Apply everything else |
| 41 | +$ terraform apply |
| 42 | + |
| 43 | +# Roll the remaining nodes |
| 44 | +$ kops rolling-update cluster --yes |
| 45 | +``` |
| 46 | + |
| 47 | +## Upgrades before Kops 1.31 |
| 48 | + |
3 | 49 | Upgrading kubernetes is very easy with kOps, as long as you are using a compatible version of kOps.
|
4 |
| -The kOps `1.18.x` series (for example) supports the kubernetes 1.16, 1.17 and 1.18 series, |
| 50 | +The kOps `1.30.x` series (for example) supports the kubernetes 1.28, 1.29, and 1.30 series, |
5 | 51 | as per the kubernetes deprecation policy. Older versions of kubernetes will likely still work, but these
|
6 |
| -are on a best-effort basis and will have little if any testing. kOps `1.18` will not support the kubernetes |
7 |
| -`1.19` series, and for full support of kubernetes `1.19` it is best to wait for the kOps `1.19` series release. |
8 |
| -We aim to release the next major version of kOps within a few weeks of the equivalent major release of kubernetes, |
9 |
| -so kOps `1.19.0` will be released within a few weeks of kubernetes `1.19.0`. We try to ensure that a 1.19 pre-release |
10 |
| -(alpha or beta) is available at the kubernetes release, for early adopters. |
| 52 | +are on a best-effort basis and will have little if any testing. kOps `1.30` will not support the kubernetes |
| 53 | +`1.31` series, and for full support of kubernetes `1.31` it is best to wait for the kOps `1.31` series release. |
| 54 | +We aim to release the next major version of kOps within a few weeks of the equivalent major release of kubernetes. |
| 55 | +We try to ensure that a pre-release (alpha or beta) is available at the kubernetes release date, for early adopters. |
11 | 56 |
|
12 |
| -Upgrading kubernetes is similar to changing the image on an InstanceGroup, except that the kubernetes version is |
| 57 | +Upgrading kubernetes is similar to changing the image on an InstanceGroup, the kubernetes version is |
13 | 58 | controlled at the cluster level. So instead of `kops edit ig <name>`, we `kops edit cluster`, and change the
|
14 | 59 | `kubernetesVersion` field. `kops edit cluster` will open your editor with the cluster, similar to:
|
15 | 60 |
|
|
0 commit comments