Video walkthrough
To see a demo of this process, watch this video:Automated Kubernetes upgrade
The recommended method to upgrade Kubernetes is to use thetalosctl upgrade-k8s command.
This will automatically update the components needed to upgrade Kubernetes safely.
Kubernetes upgrades are non-disruptive from Talos, but Kubelet upgrades may cause workloads to restart.
To trigger a Kubernetes upgrade, issue a command specifying the version of Kubernetes to upgrade to, such as:
Note that the --nodes parameter specifies the control plane node to send the API call to, but all members of the cluster will be upgraded.
To check what will be upgraded you can run talosctl upgrade-k8s with the --dry-run flag:
You should get an output similar to this:
This command runs in several phases:
- Images for new Kubernetes components are pre-pulled to the nodes to minimize downtime and test for image availability.
- Every control plane node machine configuration is patched with the new image version for each control plane component. Talos renders new static pod definitions on the configuration update which is picked up by the kubelet. The command waits for the change to propagate to the API server state.
- The command updates the
kube-proxydaemonset with the new image version. - On every node in the cluster, the
kubeletversion is updated. The command then waits for thekubeletservice to be restarted and become healthy. The update is verified by checking theNoderesource state. - Kubernetes bootstrap manifests are re-applied to the cluster. Updated bootstrap manifests might come with a new Talos version (e.g. CoreDNS version update), or might be the result of machine configuration change.
- Unneeded resources are pruned from the cluster (Talos v1.13+).
When using custom/overridden Kubernetes component images, use flags
--*-image to override the default image names.Kubernetes manifest synchronization
A Talos version change might also cause changes in the bootstrap manifests. The updated bootstrap manifests, inline manifests and extra manifests are applied to the cluster as part of the Kubernetes upgrade process. If any services were deleted or disabled, the resources associated with them will be pruned. For example if kube-proxy was disabled in the machine configuration the resources associated with it would be deleted at this stage. Pruning can be disabled by passing the--manifests-no-prune flag.
Pruning is supported from Talos and talosctl v1.13 onwards.
- Remove the inline manifest or extra manifest entry from the machine configuration.
After this step you can run
talosctl upgrade-k8s --dry-run --to <in-cluster-k8s-version>. Resources affected will be marked for pruning in the output. - Remove the resource entries from the talos tracking inventory configmap data block by running:
- Remove the
config.k8s.io/owning-inventoryannotation from the resources. - Re-apply the resource with your own field manager or remove the
metadata.managedFieldsmanually.
Synchronize declared and deployed configurations
When Kubernetes is upgraded withtalosctl upgrade-k8s, the live machine configuration on your nodes is updated with new component image versions (API server, controller manager, scheduler, kube-proxy, etc.).
If you are storing full machine configuration files (controlplane.yaml, worker.yaml) in Git, these versions will drift out of sync.
Re-applying those stale files later could unintentionally downgrade components.
That is why we do not recommend storing full machine configurations.
Version numbers for Talos, etcd, Kubernetes components, and add-ons change frequently. Maintaining these across upgrades requires editing many fields by hand.
See the Reproducible Machine Configuration guide for full instructions on handling machine configurations after version bumps.
Manual Kubernetes upgrade
Kubernetes can be upgraded manually by following the steps outlined below. They are equivalent to the steps performed by thetalosctl upgrade-k8s command.
Before running the commands below, export the k8s_release variable, replacing the placeholder with the target Kubernetes version:
The
talosctl patch mc examples use strategic-merge (YAML) patches, which work across supported Talos versions. From Talos v1.13 the machine configuration is a multi-document configuration, for which strategic-merge patches should be used rather than RFC 6902 (op/path/value) patches. A strategic-merge patch also creates the target key if it is not already present.Kubeconfig
In order to edit the control plane, you need a workingkubectl config. If you don’t already have one, you can get one by running:
API server
Patch the machine configuration with the new API server image:kube-apiserver config with:
5.
Wait for the new pod definition to propagate, then confirm the running kube-apiserver pods are using the new image version:
Controller manager
Patch the machine configuration with the new controller manager image:kube-controller-manager config with:
3.
Wait for the new pod definition to propagate, then confirm the running kube-controller-manager pods are using the new image version:
Scheduler
Patch the machine configuration with the new scheduler image:kube-scheduler config with:
3.
WWait for the new pod definition to propagate, then confirm the running kube-scheduler pods are using the new image version:
Proxy
Upgradekube-proxy through the machine configuration, in the same way as the other control plane components. The kube-proxy DaemonSet is generated from .cluster.proxy.image and is reconciled when the bootstrap manifests are applied in the next step, so its image should be set in the machine configuration rather than by editing the live DaemonSet.
Patch the machine configuration with the new proxy image:
DaemonSet is rolled out when you apply the bootstrap manifests in the next step.
Bootstrap manifests
Bootstrap manifests can be retrieved in a format which works forkubectl with the following command:
kube-proxy DaemonSet image shown in the diff matches the target version (v${k8s_release}). If it shows the previous version, set .cluster.proxy.image in the machine configuration as described in the Proxy step before applying.
Apply the manifests:
If some bootstrap resources were removed, they have to be removed from the cluster manually.
kubelet
For every node, patch the machine configuration with the new kubelet version, then wait for the kubelet to restart:kubelet restarts with the new configuration, confirm the upgrade. The VERSION column should show the new Kubernetes version for every node: