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.
Upgrading Kubernetes is non-disruptive to the cluster workloads.
To trigger a Kubernetes upgrade, issue a command specifying the version of Kubernetes to ugprade 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 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-proxy
daemonset with the new image version. - On every node in the cluster, the
kubelet
version is updated. The command then waits for thekubelet
service to be restarted and become healthy. The update is verified by checking theNode
resource 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.
Note: The upgrade-k8s
command never deletes any resources from the cluster: they should be deleted manually.
If the command fails for any reason, it can be safely restarted to continue the upgrade process from the moment of the failure.
Note: When using custom/overridden Kubernetes component images, use flags --*-image
to override the default image names.
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>
: