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:
talosctl --nodes <controlplane node> upgrade-k8s --to ${k8s_release}
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:
To upgrade Kubernetes from ${k8s_prev_release} to v${k8s_release} run:
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+).
Note: 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.
Note: Pruning is supported from Talos and talosctl v1.13 onwards.From Talos v1.13 onwards, all Kubernetes manifests are applied via Kubernetes Server-Side Apply. Talos forces ownership of all fields it applies, even if they have a different field manager. If you wish to manage a resource previously applied by Talos, you need to take the following steps:
- 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:
- 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.
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 machine configuration usingtalosctl patch command:
.cluster.apiServer.image key.
Also the machine configuration can be edited manually with talosctl -n <IP> edit mc --mode=no-reboot.
Capture the new version of kube-apiserver config with:
5.
Wait for the new pod definition to propagate to the API server state (replace talos-default-controlplane-1 with the node name):
Controller manager
Patch machine configuration usingtalosctl patch command:
.cluster.controllerManager.image key.
Capture new version of kube-controller-manager config with:
3.
Wait for the new pod definition to propagate to the API server state (replace talos-default-controlplane-1 with the node name):
Scheduler
Patch machine configuration usingtalosctl patch command:
.cluster.scheduler.image key.
Capture new version of kube-scheduler config with:
3.
Wait for the new pod definition to propagate to the API server state (replace talos-default-controlplane-1 with the node name):
Proxy
In the proxy’sDaemonSet, change:
DaemonSet, run:
Bootstrap manifests
Bootstrap manifests can be retrieved in a format which works forkubectl with the following command:
Note: if some bootstrap resources were removed, they have to be removed from the cluster manually.
kubelet
For every node, patch machine configuration with new kubelet version, wait for the kubelet to restart with new version:kubelet restarts with the new configuration, confirm upgrade with kubectl get nodes <name>: