talosctl commands which facilitate machine configuration updates:
talosctl apply-configto apply configuration from the filetalosctl edit machineconfigto launch an editor with existing node configuration, make changes and apply configuration backtalosctl patch machineconfigto apply automated machine configuration via JSON patch
- apply change immediately (default,
--mode=autoor--mode=no-reboot): the new configuration is applied to the running node - apply change on next reboot (
--mode=staged): change is staged to be applied after a reboot, but node is not rebooted - apply change with automatic revert (
--mode=try): change is applied immediately (if not possible, returns an error), and reverts it automatically in 1 minute if no configuration update is applied
Note: applying change on next reboot (The--mode=staged) doesn’t modify current node configuration, so next call totalosctl edit machineconfig --mode=stagedwill not see changes
--mode=reboot option was removed in Talos 1.14, and --mode=interactive was removed in an earlier release.
When a change does need a reboot (see below), reboot the node explicitly with talosctl reboot after applying the configuration.
This keeps the reboot under your control, so it can be sequenced with cordoning and draining the node.
Additionally, there is also talosctl get machineconfig v1alpha1 -o jsonpath='{.spec}', which retrieves the current node configuration API resource and return just the machine configuration in the .spec field.
It can be used to modify the configuration locally before being applied to the node.
Changes which might need a reboot
Talos applies the new configuration to the running node, but a few settings are not fully picked up by a node which is already running, and need a reboot to take effect:-
.cluster.etcd: theetcdservice reads its settings — image, extra arguments, advertised and listen addresses — when it starts. Talos does not restartetcdon a configuration change, since restarting a control plane member is disruptive and is not something Talos does implicitly. Reboot the node to pick up the new settings: -
Environment variables (
EnvironmentConfigor.machine.env): Talos picks up the new values on the fly, but a service which is already running keeps the environment it was started with, so a variable consumed by a service only takes effect once that service restarts. Removing a variable from the configuration does not unset it on a running node either. -
Kernel modules (
KernelModuleConfigor.machine.kernel.modules): Talos loads modules which were added to the configuration, but it never unloads modules, and module parameters are only applied when the module is loaded for the first time. Removing a module, or changing the parameters of a module which is already loaded, has no effect until a reboot. -
Volume encryption keys: the
encryptionsection of a volume document is applied when the volume is unlocked, so rotating a key takes a reboot for the volume to be re-encrypted with the new key.
UnattendedInstallConfig and the deprecated .machine.install
are only used during an install or an upgrade, so changing them has no effect on a node which is already installed — not even after a reboot.
talosctl apply-config
This command is traditionally used to submit initial machine configuration generated by talosctl gen config to the node.
It can also be used to apply configuration to running nodes.
The initial YAML for this is typically obtained using talosctl get machineconfig v1alpha1 -o jsonpath='{.spec}' > machineconfig.yaml.
Example:
apply-config can also be invoked as apply machineconfig:
Note: when a Talos node is running in the maintenance mode it’s necessary to provide --insecure (-i) flag to connect to the API and apply the config.
talosctl edit machineconfig
Command talosctl edit loads current machine configuration from the node and launches configured editor to modify the config.
If config hasn’t been changed in the editor (or if updated config is empty), update is not applied.
Note: Talos uses environment variablesExample:TALOS_EDITOR,EDITORto pick up the editor preference. If environment variables are missing,vieditor is used by default.
talosctl patch machineconfig
Command talosctl patch works similar to talosctl edit command - it loads current machine configuration, but instead of launching configured editor
it applies a set of patches to the configuration and writes the result back to the node.
Example, updating kubelet version by patching the KubeletConfig document:
Updating kube-apiserver version via the KubeAPIServerConfig document,
reverting the change automatically if it is not confirmed within a minute:
A patch might be applied to multiple nodes when multiple IPs are specified:
file (or @file) syntax, which is usually more readable for document patches: