Skip to content

Commit

Permalink
Merge pull request #759 from Danil-Grigorev/restore-docs
Browse files Browse the repository at this point in the history
Add snapshot restore quickstart doc
  • Loading branch information
alexander-demicev authored Oct 3, 2024
2 parents 667a3fe + 8cc74d4 commit f79221a
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
73 changes: 72 additions & 1 deletion exp/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
# Experimental(Technical Preview)

This is a technical preview of the experimental features that are currently being developed in the project. These features are not yet ready for production use and are subject to change.
This is a technical preview of the experimental features that are currently being developed in the project. These features are not yet ready for production use and are subject to change.

# turtles-etcd-restore

## Setting up the environment

To set up the environment, navigate to the root of the repository and run:

```bash
export RANCHER_HOSTNAME="<hostname>"
export NGROK_API_KEY="<api-key>"
export NGROK_AUTHTOKEN="<api-authtoken>"

make dev-env
```

The `Makefile` target sets up the environment by executing the `scripts/etcd-backup-restore-dev.sh`
script with the `RANCHER_HOSTNAME` argument. Under the hood, it performs the following steps:

1. Creates a kind cluster.
2. Deploys cert-manager, CAPI Operator with Rancher Turtles.
3. Deploys CAPRKE2 provider.
4. Deploys Docker provider.
5. Deploys ngrok.
6. Deploys Rancher accessible via ngrok.

Environment is prepared for cluster creation using CAPRKE2. UI is accessible via `RANCHER_HOSTNAME`.

## Creating a cluster

To deploy an RKE2 cluster with automatic snapshots enabled:

```bash
export CONTROL_PLANE_MACHINE_COUNT=1
export WORKER_MACHINE_COUNT=1
export CLUSTER_NAME=rke2
export KUBERNETES_VERSION=v1.30.4
export RKE2_VERSION=v1.30.4+rke2r1

# Prevent replacing lb-config variables by envsubst
export address='$address'
export server='$server'

envsubst < test/e2e/data/cluster-templates/docker-rke2.yaml | kubectl apply -f -
```

## Performing the snapshot and restore

When all machines in the cluster are ready, automatic ETCDMachineSnapshot object should appear on the management cluster soon.

```bash

kubectl get etcdmachinesnapshot -A
```

To perform a restore run the following command:

```bash
export CLUSTER_NAMESPACE=default
export CLUSTER_NAME=rke2
export ETCD_MACHINE_SNAPSHOT_NAME="<snapshot_name_from_the_output>"

envsubst < etcdrestore/examples/etcd-restore.yaml | kubectl apply -f -
```

## Cleanup

To clean up the environment, run the following command from the root of the repo:

```bash
make clean-dev-env
```
8 changes: 8 additions & 0 deletions exp/etcdrestore/examples/etcd-restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiversion: turtles-capi.cattle.io/v1alpha1
kind: ETCDSnapshotRestore
metadata:
name: example-restore
namespace: ${CLUSTER_NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
etcdMachineSnapshotName: ${ETCD_MACHINE_SNAPSHOT_NAME}
13 changes: 13 additions & 0 deletions scripts/turtles-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kubectl rollout status deployment coredns -n kube-system --timeout=90s
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo add capi-operator https://kubernetes-sigs.github.io/cluster-api-operator
helm repo add jetstack https://charts.jetstack.io
helm repo add ngrok https://charts.ngrok.com
helm repo update

helm install cert-manager jetstack/cert-manager \
Expand All @@ -51,6 +52,15 @@ helm install capi-operator capi-operator/cluster-api-operator \

kubectl rollout status deployment capi-operator-cluster-api-operator -n capi-operator-system --timeout=180s

helm upgrade ngrok ngrok/kubernetes-ingress-controller \
--install \
--wait \
--timeout 5m \
--set credentials.apiKey=$NGROK_API_KEY \
--set credentials.authtoken=$NGROK_AUTHTOKEN

kubectl apply -f test/e2e/data/rancher/ingress-class-patch.yaml

helm install rancher rancher-latest/rancher \
--namespace cattle-system \
--create-namespace \
Expand All @@ -64,4 +74,7 @@ helm install rancher rancher-latest/rancher \

kubectl rollout status deployment rancher -n cattle-system --timeout=180s

kubectl apply -f test/e2e/data/rancher/rancher-service-patch.yaml
envsubst < test/e2e/data/rancher/rancher-setting-patch.yaml | kubectl apply -f -

tilt up

0 comments on commit f79221a

Please sign in to comment.