- Home
- Configuration
- Restore
Restore#
To restore an MKE 4 cluster, you bootstrap a new cluster fromm a backup and then bring the rest of the cluster back online.
| Restore scenario | Description |
|---|---|
| Restore to the same configuration | Recreate the cluster with the same nodes, roles, and configuration as the backup. Commonly used to rollback after an unwanted change. |
| Restore to a different node configuration | Restore onto nodes that differ from the original, such as different names, IP addresses, labels, or annotations. |
| Disaster recovery | Recover onto new infrastructure, as your original infrastructure is no longer available and the original cluster is irretrievable. |
Warning
-
You must flatten the nodes that you use for disaster recovery, as they may have previously been a part of any MKE 4 or k0s cluster.
-
You must configure the bootstrap node appropriately before you attempt disaster recovery, meeting the same
fs.inotifylimits required of every cluster node. Refer to System requirements for the required values, and apply them immediately withsudo sysctl <parameter>=<value>for each one, in addition to persisting them as described. -
Verify that the bootstrap node has enough free space in the directory where
k0s restoreunpacks the archive. The default directory is/tmp. To use a different directory, pass--temp-dir, or setspec.backup.tempDirin the k0s configuration before you create the backup. The required space equals the uncompressed size of the k0s archive in the backup. This archive includes the OCI image bundle directory and can reach several GB on offline clusters.
Important
-
You cannot use
mkectl restorewith the backup thatmkectl upgradecreates automatically,mke4preupgradesnapshot<timestamp>.tar. If the automatic rollback of a failed upgrade does not complete, restore the backup that you created before the upgrade. Use the samemkectlversion that created that backup. -
Do not change the DNS name for the load balancer while performing disaster recovery. If you opt to deploy a new load balancer, ensure that it uses the same DNS name as the one in use by the original cluster.
Info
- During disaster recovery, the original nodes are not accessible in the new environment. As such, because the entire cluster will initially be brought up on a single node, some of the containers and processes may encounter resource issues. You can resolve these issues either by using a highly resourced node or through operating system configuration.
Bootstrap a new cluster#
The first step in the restore process is to bootstrap a new cluster on a single node from the backup tar file:
-
Prepare a
hosts.yamlfile that contains the information needed to SSH into the bootstrap node:hosts: - ssh: address: <bootstrap-node-ip-address> user: <SSH-user-name> port: <ssh port> keyPath: <full-path-to-SSH-private-key> role: controller+worker -
Restore the cluster:
mkectl restore -l debug --hosts-path <full-path-to-hosts.yaml-file-on-node-from-which-you-run-mkectl> --name <backup-tar-file>If the archive is encrypted, add
--passphrase. To verify the archive's integrity, add--md5with the checksum you recorded when you created the backup:mkectl restore --hosts-path <hosts-file> --name <backup-tar-file> \ --passphrase - --md5 <checksum> --force \ < /path/to/passphrase-fileIf the archive contains a non-current configuration, also pass
--accept-noncurrent-config.mkectlruns the passphrase and checksum checks before it makes any change to the cluster:Condition Result Archive not encrypted, --passphraseomittedRestore proceeds. Archive not encrypted, --passphrasespecifiedRestore fails.
Re-run the command without--passphrase.Archive encrypted, --passphraseomittedRestore fails.
For a scheduled backup, the error names the Secret and key identifier of the retained passphrase to use. For a manual backup, it asks for the passphrase supplied when the archive was created.Archive encrypted, passphrase incorrect Restore fails to decrypt the archive. Backups require the matching
mkectlbuildRestore requires the matching
mkectlbuild that created the backup. Store eachmkectlbinary with the backups it creates, and retain it for as long as you retain those backups.The
mkectl restorecommand prompts you to confirm before it bootstraps the cluster. If the archive contains a configuration that was not current at backup time, the command also displays the configuration provenance and prompts you to accept that configuration.Each prompt has its own flag:
--forceskips the bootstrap confirmation.--accept-noncurrent-configaccepts the non-current configuration.
For unattended restore, or when you read the passphrase from standard input with
--passphrase -, pass both flags:mkectl restore --hosts-path <hosts-file> --name <backup-tar-file> \ --passphrase - --force --accept-noncurrent-config \ < /path/to/passphrase-fileFor details, refer to Configuration snapshot fallback.
Restore an archive from an earlier MKE 4 release with the
mkectlbinary that created it.Authenticated registries
If the cluster pulls from a registry that requires authentication, pass the image and chart registry credentials to the
mkectl restorecommand as well. Because the cluster does not exist during the restore,mkectlcannot read the credentials from it. For more information, refer to Supply the credentials during restore.
Add additional cluster nodes#
After you restore the bootstrap node, join the remaining nodes:
-
Prepare a hosts file that lists the remaining control plane nodes and the Linux worker nodes. Do not include the bootstrap node or the Windows worker nodes. The
--scopeflag of themkectl node addcommand selects which entries in the file each run acts on, so you can use the same file for steps 2 and 3.hosts: - role: controller+worker ssh: address: <controller-2-ip-address> user: <SSH-user-name> port: <ssh port> keyPath: <full-path-to-SSH-private-key> - role: controller+worker ssh: address: <controller-3-ip-address> user: <SSH-user-name> port: <ssh port> keyPath: <full-path-to-SSH-private-key> - role: worker ssh: address: <worker-1-ip-address> user: <SSH-user-name> port: <ssh port> keyPath: <full-path-to-SSH-private-key> -
Join the control plane nodes:
mkectl node add --hosts-path <hosts-file> --scope controller+workerThe control plane nodes join one at a time. Because
mkectltakes a cluster backup before and after adding control planes, which cause changes to etcd membership, you must pass either --passphraseor--no-passphrase. To skip the backups, pass--skip-snapshotinstead. For more information, refer to Backups. -
Join the Linux worker nodes:
mkectl node add --hosts-path <hosts-file> --scope worker -
If the cluster has Windows worker nodes, join them last with the
mkectl applycommand, becausemkectl node adddoes not support Windows nodes.Warning
Do not apply the
mke4.yamlfile thatmkectl restorewrites. That file lists only the hosts from the restore hosts file, andmkectl applyfails when the control plane nodes inspec.hostsdo not match those of the cluster, asmkectl applydoes not add or remove control plane nodes. Use the output ofmkectl config getinstead.-
Save the current cluster configuration, which lists every node that has joined the cluster:
mkectl config get > mke4.yaml -
Add the Windows worker nodes to the end of the
spec.hostslist inmke4.yaml. -
Run the
mkectl applycommand:mkectl apply -f mke4.yaml
-
Note
The mkectl config get command returns the configuration from the backup, as restored,
with the joined nodes added. Configuration changes made after the backup
was taken are not included and must be re-applied.
Rebalance the nodes#
Info
Rebalancing is not a factor for clusters that have a single controller node.
After you restore an MKE 4 cluster, join all of the remaining control plane
nodes with a single mkectl node add command. The command automatically
redistributes the MKE system components across the cluster, so no manual
rebalancing is required. Joining the nodes in one invocation ensures that the
redistribution occurs only once. For more information, refer to
Workload redistribution.