Skip to content

Commit c8b5c03

Browse files
authored
doc: Add documentation for backup feature (#1547)
The DevWorkspaceOperatorConfig was extended to enable the workspace backup process. This commits describes the feature and how to configure it. Signed-off-by: Ales Raszka <araszka@redhat.com>
1 parent 948666e commit c8b5c03

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

docs/dwo-configuration.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,107 @@ Cleanup CronJob configuration fields:
107107
- **`retainTime`**: The duration time in seconds since a DevWorkspace was last started before it is considered stale and eligible for cleanup. Default: 2592000 seconds (30 days).
108108
- **`dryRun`**: Set to `true` to run the cleanup job in dry-run mode. In this mode, the job logs which DevWorkspaces would be removed but does not actually delete them. Set to `false` to perform the actual deletion. Default: `false`.
109109

110+
## Configuring Backup CronJob
111+
112+
The DevWorkspace backup job allows for periodic backups of DevWorkspace data to a specified backup location.
113+
Once enabled and configured, the backup job will run at defined intervals to create backups of DevWorkspace data.
114+
The backup controller depends on an OCI-compatible registry e.g., [quay.io](https://quay.io/) used as an image artifact storage for backup archives.
115+
116+
The backup makes a snapshot of Workspace PVCs and stores them as tar.gz archives in the specified OCI registry.
117+
**Note:** By default, the DevWorkspace backup job is disabled.
118+
119+
120+
Backup CronJob configuration fields:
121+
122+
- **`enable`**: Set to `true` to enable the backup job, `false` to disable it. Default: `false`.
123+
- **`schedule`**: A Cron expression defining how often the backup job runs. Default: `"0 1 * * *"`.
124+
- **`registry.path`**: A base registry location where the backup archives will be pushed.
125+
The value provided for registry.path is only the first segment of the final location. The full registry path is assembled dynamically, incorporating the name of the workspace and the :latest tag, following this pattern:
126+
`<registry.path>/<devworkspace-name>:latest`
127+
128+
- **`registry.authSecret`**: (Optional) The name of the Kubernetes Secret containing credentials to access the OCI registry. If not provided, it is assumed that the registry is public or uses integrated OpenShift registry.
129+
- **`oras.extraArgs`**: (Optional) Additional arguments to pass to the `oras` CLI tool during push and pull operations.
130+
131+
132+
There are several configuration options to customize the logic:
133+
134+
### Integrated OpenShift container registry
135+
This option is available only on OpenShift clusters with integrated container registry enabled and requires no additional configuration.
136+
137+
To enable the backup use following configuration in the global DWOC:
138+
139+
```yaml
140+
apiVersion: controller.devfile.io/v1alpha1
141+
kind: DevWorkspaceOperatorConfig
142+
metadata:
143+
name: devworkspace-operator-config
144+
namespace: $OPERATOR_INSTALL_NAMESPACE
145+
config:
146+
routing:
147+
defaultRoutingClass: basic
148+
workspace:
149+
backupCronJob:
150+
enable: true
151+
registry:
152+
path: default-route-openshift-image-registry.apps.{cluster ID}.openshiftapps.com
153+
schedule: '0 */4 * * *' # cron expression with backup frequency
154+
imagePullPolicy: Always
155+
```
156+
157+
**Note:** The `path` field must contain the URL to your OpenShift integrated registry given by the cluster.
158+
159+
Once the backup job is finished, the backup archives will be available in the DevWorkspace namespace under a repository
160+
with a matching Devworkspace name.
161+
162+
### Regular OCI-compatible registry
163+
To use a regular OCI-compatible registry for backups, you need to provide registry credentials. Depending on your
164+
RBAC policy, the token can be provided via a secret in the operator namespace or in each DevWorkspace namespace.
165+
Having the secret in the DevWorkspace namespace allows for using different registry accounts per namespace with more
166+
granular access control.
167+
168+
169+
```yaml
170+
kind: DevWorkspaceOperatorConfig
171+
apiVersion: controller.devfile.io/v1alpha1
172+
metadata:
173+
name: devworkspace-operator-config
174+
namespace: $OPERATOR_INSTALL_NAMESPACE
175+
config:
176+
routing:
177+
defaultRoutingClass: basic
178+
workspace:
179+
backupCronJob:
180+
enable: true
181+
registry:
182+
authSecret: my-secret
183+
path: quay.io/my-company-org
184+
schedule: '0 */4 * * *'
185+
imagePullPolicy: Always
186+
```
187+
The `authSecret` must point to a real Kubernetes Secret of type `kubernetes.io/dockerconfigjson` containing credentials to access the registry.
188+
189+
To create one you can use following command:
190+
191+
```bash
192+
kubectl create secret docker-registry my-secret --from-file=config.json -n devworkspace-controller
193+
```
194+
The secret must contain a label `controller.devfile.io/watch-secret=true` to be recognized by the DevWorkspace Operator.
195+
```bash
196+
kubectl label secret my-secret controller.devfile.io/watch-secret=true -n devworkspace-controller
197+
```
198+
199+
### Restore from backup
200+
We are aiming to provide automated restore functionality in future releases. But for now you can still
201+
manually restore the data from the backup archives created by the backup job.
202+
203+
Since the backup archive is available in OCI registry you can use any OCI compatible tool to pull
204+
the archive locally. For example using [oras](https://github.com/oras-project/oras) cli tool:
205+
206+
```bash
207+
oras pull <registry-path>/<devworkspace-name>:latest
208+
```
209+
The archive will be downloaded as a `devworkspace-backup.tar.gz` file which you can extract and restore the data.
210+
110211
## Configuring PVC storage access mode
111212

112213
By default, PVCs managed by the DevWorkspace Operator are created with the `ReadWriteOnce` access mode.

0 commit comments

Comments
 (0)