Configure Snapshots
This topic provides information about how to configure the Velero Backup resource to enable Replicated KOTS snapshots for an application.
For more information about snapshots, see About Backup and Restore with snapshots.
Configure Snapshots
Add a Velero Backup custom resource (kind: Backup
, apiVersion: velero.io/v1
) to your release and configure it as needed. After configuring the Backup resource, add annotations for each volume that you want to be included in backups.
To configure snapshots for your application:
-
In a new release containing your application files, add a Velero Backup resource (
kind: Backup
andapiVersion: velero.io/v1
):apiVersion: velero.io/v1
kind: Backup
metadata:
name: backup
spec: {} -
Configure the Backup resource to specify the resources that will be included in backups.
For more information about the Velero Backup resource, including limitations, the list of supported fields for snapshots, and an example, see Velero Backup Resource for Snapshots.
-
(Optional) Configure backup and restore hooks. For more information, see Configure Backup and Restore Hooks for Snapshots.
-
For each volume that requires a backup, add the
backup.velero.io/backup-volumes
annotation. The annotation name isbackup.velero.io/backup-volumes
and the value is a comma separated list of volumes to include in the backup.Why do I need to use the backup annotation?
By default, no volumes are included in the backup. If any pods mount a volume that should be backed up, you must configure the backup with an annotation listing the specific volumes to include in the backup.
Example:
In the following Deployment manifest file,
pvc-volume
is the only volume that is backed up. Thescratch
volume is not included in the backup because it is not listed in annotation on the pod specification.apiVersion: apps/v1
kind: Deployment
metadata:
name: sample
labels:
app: foo
spec:
replicas: 1
selector:
matchLabels:
app: foo
template:
metadata:
labels:
app: foo
annotations:
backup.velero.io/backup-volumes: pvc-volume
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-webserver
volumeMounts:
- name: pvc-volume
mountPath: /volume-1
- name: scratch
mountPath: /volume-2
volumes:
- name: pvc-volume
persistentVolumeClaim:
claimName: test-volume-claim
- name: scratch
emptyDir: {} -
For any Helm charts in your release that are deployed with the HelmChart v2 custom resource, configure the HelmChart custom resource
optionalValues
key to conditionally add the following labels to all resources that you want to be included in backups:kots.io/backup: velero
kots.io/app-slug: APP_SLUG
, whereAPP_SLUG
is the unique slug of the application. You can inject the application slug using therepl{{ LicenseFieldValue "appSlug" }}
template function.
Use the following
when
statement so that the labels are only applied to resources when the customer license has theisSnapshotSupported
entitlement:when: repl{{ LicenseFieldValue "isSnapshotSupported" }}
For more information about working with the
optionalValues
key, see optionalValues in HelmChart v2.Example:
# kots.io/v1beta2 HelmChart custom resource
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: samplechart
spec:
optionalValues:
# add kots backup labels only when the
# license supports snapshots
- when: repl{{ LicenseFieldValue "isSnapshotSupported" }}
recursiveMerge: true
values:
mariadb:
commonLabels:
kots.io/backup: velero
kots.io/app-slug: repl{{ LicenseFieldValue "appSlug" }}
podLabels:
kots.io/backup: velero
kots.io/app-slug: repl{{ LicenseFieldValue "appSlug" }} -
(Optional) Configure exclusions. By default, Velero includes backups of all of the Kubernetes objects in the namespace.
To exclude a resource from backups, add the
velero.io/exclude-from-backup=true
label. The following example shows a Secret with thevelero.io/exclude-from-backup
label:apiVersion: apps/v1
kind: Secret
metadata:
name: sample
labels:
velero.io/exclude-from-backup: "true"
stringData:
uri: Secret To Not Include -
If you distribute multiple applications with Replicated, repeat these steps for each application. Each application must have its own Backup resource to be included in a full backup with snapshots.
-
(kURL Only) If your application supports installation with Replicated kURL, Replicated recommends that you include the kURL Velero add-on so that customers do not have to manually install Velero in the kURL cluster. For more information, see Create a kURL Installer.