Skip to content

Instantly share code, notes, and snippets.

@superseb
Created August 20, 2019 09:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superseb/7d7d9654886f0550a4567b45c21e13ac to your computer and use it in GitHub Desktop.
Save superseb/7d7d9654886f0550a4567b45c21e13ac to your computer and use it in GitHub Desktop.
Rancher/RKE etcd snapshot intro

Rancher/RKE etcd snapshot intro

Brief description of what is done where/how/what etc

Repositories/tools involved:

Rancher

In Rancher, "everything" is done using controllers. The etcdbackup controller takes care of the snapshots, see pkg/controllers/management/etcdbackup/etcdbackup.go. Functions in here link to function of the kontainer-engine rke driver (https://github.com/rancher/kontainer-engine/blob/master/drivers/rke/rke_driver.go) which then usually calls a cmd function in RKE.

Example of taking a snapshot:

  • Create in pkg/controllers/management/etcdbackup/etcdbackup.go
  • calls c.etcdSaveWithBackoff
  • calls c.backupDriver.ETCDSave
  • ETCDSave is defined in the kontainer driver in kontainer-engine, which then calls the function defined in the driver that is used (in this case, RKE)
  • In drivers/rke_driver.go the function ETCDSave is defined, which then calls cmd.SnapshotSaveEtcdHosts from rke/cmd

The config for the cluster (and thus for the backups/snapshots) is stored and can be shown using Edit as YAML or View in API for the cluster. These values are used when snapshots are taken/cleaned.

Main differences with RKE

In RKE, there is no state to be stored, so we run etcd-rolling-backups on the nodes to make sure periodic snapshots are made. In Rancher, this is handled by the controller. For one-time snapshots, RKE CLI can be used for RKE, in Rancher, it's an API call which then follows the same trail as mentioned above. Keep in mind that rke-tools is still the link in all operations, as this is used to any operation for etcd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment