Object Specifications Reference

The K8up operator includes several Custom Resource Definitions (CRDs) which get added to the cluster by the helm chart or which have to be added manually. Here they are explained in more detail.

 A generated API documentation is available at API reference.

Schedule

With the schedule CRD it’s possible to put all other CRDs on a schedule.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Schedule
name: schedule-test
spec:
backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials
archive:
schedule: '0 * * * *'
restoreMethod:
s3:
endpoint: http://10.144.1.224:9000
bucket: restoremini
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials
backup:
schedule: '* * * * *'
keepJobs: 4
promURL: http://10.144.1.224:9000
check:
schedule: '*/5 * * * *'
promURL: http://10.144.1.224:9000
prune:
schedule: '*/2 * * * *'
retention:
keepLast: 5
keepDaily: 14``````

Settings

• `archive`: see archive for further explaination

• `backend`: see backend for further explanaition

• `check`: see check for further explanaition

• `prune`: see prune for further explanaition

Restore

It’s possible to define different kinds of restore jobs. Currently these kinds of restores are supported:

• To a PVC

• To S3 as tar.gz

Example for a restore to a PVC:

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Restore
name: restore-test

spec:
tags:
- prod
- archive
restoreMethod:
folder:
claimName: restore

backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials

This will restore the latest snapshot from `http://10.144.1.224:9000` to the PVC with the name `restore`.

Settings

• `backend`: see backend for further explanation

• `restoreMethod`: is either `s3` or `folder`. For s3 please see `backend` for `folder` you just need to provide a valid claim name as shown in the example above

• `restoreFiler`: a filter passed to the underlying Restic, which will be used. Please consult the Restic docs for valid path filters.

• `snapshot`: valid snapshot ID that should get restored. If not provided, the most recent one will be restored.

• `keepJobs`: amount of jobs that should be left after cleanup, for example how many job/pod objects should be left after they finished. Defaults to 6. Only applicable when used within a schedule.

• `tags`: list of tags to be considered for the restore. They’re ignored if a snapshot ID is provided.

Archive

The archive CRD will take the latest snapshots from each namespace/project in the repository. Thus you should only run one schedule per repository for archival as there’s a chance that you’ll archive snapshots more than once.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Archive
name: archive-test
spec:
name: backup-repo
restoreMethod:
s3:
endpoint: http://10.144.1.224:9000
bucket: restoremini
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials
backend:
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials

Archive is just a wrapper for restore, intended for use with the schedule. Will restore all namespaces on a given backend to a given S3 location.

Backup

This will trigger a single backup.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Backup
name: k8up-test
spec:
tags:
- prod
- archive
- important
keepJobs: 4
backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials
promURL: http://10.144.1.224:9000``````

Settings

• `backend`: see backend

• `keepJobs`: amount of jobs that should be left after cleanup, for example how many job/pod objects should be left after they finished. Defaults to 6. Only applicable when used within a schedule.

• `promURL`: sends backup statistics to this Prometheus pushgateway while the backups are running.

• `statsURL`: will send a JSON webhook containing backup information information to this endpoint. Can be used to gather a list with available backups.

• `tags`: list of tags to be added to the backup. Can be used in restores and archives again.

Check

This will trigger a single check run on the repository.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Check
name: check-test
spec:
backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials
promURL: http://10.144.1.224:9000``````

Settings

• `statsURL`: will send a JSON webhook containing check information information to this endpoint.

• `backend`: see backend

• `keepJobs`: amount of jobs that should be left after cleanup, for example how many job/pod objects should be left after they finished. Defaults to 6. Only applicable when used within a schedule.

Prune

This will trigger a single prune run, and delete the snapshots according to the defined retention rules. This one needs to run exclusively on the repository. No other jobs must run on the same repository while this one is still running. The Operator ensures that the prune will run exclusively on the repository when run on a schedule. If manually triggering a prune the wrestic locking will kick in and prevent it from damaging the repository. It will also fail the whole Pod in that case.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: Prune
name: prune-test
spec:
retention:
keepLast: 5
keepDaily: 14
backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials

Settings

• `retention`: see retention

• `backend`: see backend

• `keepJobs`: amount of jobs that should be left after cleanup, for example how many job/pod objects should be left after they finished. Defaults to 6. Only applicable when used within a schedule.

Retention

Retention is part of the prune object. It defines how the retention of a given backend should look like. Most upstream Restic rules are supported except for the ones working with labels. Please see the upstream Restic docs for more info.

``````retention:
keepLast: 5
keepDaily: 14``````

List of available settings:

• keepLast

• keepHourly

• keepDaily

• keepWeekly

• keepMonthly

• keepYearly

• keepTags

 Please don’t confuse `tags` and `keepTags` here. If you specify `keepTags` it will remove all snapshots that don’t have the tag! If you use the `tags` array it will apply the retention only to snapshots with that specific tag. That way there can be multiple backup sets on a repository, for example `prod` and `dev`.

Backend

``````backend:
name: backup-repo
s3:
endpoint: http://10.144.1.224:9000
bucket: k8up
accessKeyIDSecretRef:
name: backup-credentials
secretAccessKeySecretRef:
name: backup-credentials

Settings

• `repoPasswordSecretRef`: Kubernetes secret reference containing the Restic encryption key.

• `s3`: see s3

• `azure`: see azure

• `gcs`: see gcs

• `b2`: see b2

• `local`: see local

• `swift`: see swift

• `rest`: see rest

 Make sure to configure only one storage type!
 Don’t lose the encryption key or you won’t be able to access your backup data again! Keep a copy of that somewhere outside of the actual cluster.

S3

Settings:

• `endpoint`: http(s) endpoint of the S3 instance

• `bucket`: name of the bucket that should be used

• `accessKeyIDSecretRef`: Kubernetes secret reference containing the the Access Key ID

• `secretAccessKeySecretRef`: Kubernetes secret reference containing the Secret Access Key

Azure

Settings:

• `container`: name of the container that should be used

• `accountNameSecretRef`: Kubernetes secret reference containing the account name

• `accountKeySecretRef`: Kubernetes secret reference containing the account key

GCS

Settings:

• `projectIDSecretRef`: Kubernetes secret reference containing the Google project ID

• `accessTokenSecretRef`: Kubernetes secret reference containing the Google access token

• `bucket`: name of the bucket that should be used

B2

Settings:

• `path`: Path of the B2 instance

• `bucket`: name of the bucket that should be used

• `accountIDSecretRef`: Kubernetes secret reference containing the account ID

• `accountKeySecretRef`: Kubernetes secret reference containing the account key

Local

Settings:

• `mountPath`: MountPath inside wrestic

Swift

Settings:

• `path`: Path of the Swift instance

• `container`: name of the container that should be used

REST

Settings:

• `url`: URL of the Rest server instance (include scheme like `https://` on your own)

• `userSecretRef`: Kubernetes secret reference containing the basic auth user

• `passwordSecretReg`: Kubernetes secret reference containing the basic auth password

PreBackupPod

PreBackupPods are objects that live in the namespace that should be backed up. They’re completely optional though. Their main goal is to provide some sort of pre backup scripts. They can be used for various use cases though, see PreBackup pods.

``````apiVersion: backup.appuio.ch/v1alpha1
kind: PreBackupPod
name: mysqldump
spec:
backupCommand: mysqldump -u$USER -p$PW -h \$DB_HOST --all-databases
pod:
spec:
containers:
- env:
- name: USER
value: dumper
- name: PW
value: topsecret
- name: DB_HOST
command:
- 'sleep'
- '9999999'
imagePullPolicy: Always
name: mysqldump``````

Settings

• `backupCommand`: command that should get executed within the pod. Attention the command should output its data to stdout so that wrestic can pick it up correctly

• `fileExtension`: as this leverages the stdin backup capabilities of Restic it will generate a virtual file. That file name is by default just the name of the PreBackup pod. But to make restores easier you can define a file extension, that gets appended to the filename. For example: ".sql" for a mysql dump

• `pod`: pod is default `podTemplateSpec` of Kubernetes.

EffectiveSchedule

An `EffectiveSchedule` is a status object that persists generated schedule definitions when using K8up specific schedules like `@daily-random`. They are completely controller-managed in the controller namespace. Users should not have the need to interact with them. There is an `EffectiveSchedule` for each job type a `Schedule` object can define.

``````apiVersion: v1
kind: List
items:
- apiVersion: backup.appuio.ch/v1alpha1
kind: EffectiveSchedule
name: backup-dll789k5qql624wx
namespace: k8up-system
spec:
effectiveSchedules:
- name: schedule-test
namespace: default
generatedSchedule: 4 * * * *
jobType: backup
- apiVersion: backup.appuio.ch/v1alpha1
kind: EffectiveSchedule
name: check-qhmm4xmgsrwmj4dh
namespace: k8up-system
spec:
effectiveSchedules:
- name: schedule-test
namespace: default
generatedSchedule: 44 * * * *
jobType: check``````

`EffectiveSchedules` are being deleted when there are no more references to `Schedules`.

Settings

• `spec.generatedSchedule`: schedule definition that was translated, e.g. from `@hourly-random` to `4 * * * *`.

• `spec.jobType`: The K8up job type this resource is applicable to.

• `spec.scheduleRefs`: A list of `Schedules` for which the generated schedule applies to.