Skip to content

Commit

Permalink
Update the CRD for kopia integration
Browse files Browse the repository at this point in the history
This commit adds additional fields to podvolumebackup
and podvolumerestore.  The resticrepository will be renamed to
backuprepository

Signed-off-by: Daniel Jiang <[email protected]>
  • Loading branch information
reasonerjt committed Jul 20, 2022
1 parent 5693993 commit a422c9c
Show file tree
Hide file tree
Showing 33 changed files with 633 additions and 452 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5135-reasonerjt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the CRD for kopia integration
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: resticrepositories.velero.io
name: backuprepositories.velero.io
spec:
group: velero.io
names:
kind: ResticRepository
listKind: ResticRepositoryList
plural: resticrepositories
singular: resticrepository
kind: BackupRepository
listKind: BackupRepositoryList
plural: backuprepositories
singular: backuprepository
scope: Namespaced
versions:
- additionalPrinterColumns:
Expand All @@ -37,7 +37,7 @@ spec:
metadata:
type: object
spec:
description: ResticRepositorySpec is the specification for a ResticRepository.
description: BackupRepositorySpec is the specification for a BackupRepository.
properties:
backupStorageLocation:
description: BackupStorageLocation is the name of the BackupStorageLocation
Expand All @@ -48,11 +48,11 @@ spec:
be run.
type: string
resticIdentifier:
description: ResticIdentifier is the full restic-compatible string
description: ResticIdentifier is the full backup-compatible string
for identifying this repository.
type: string
volumeNamespace:
description: VolumeNamespace is the namespace this restic repository
description: VolumeNamespace is the namespace this backup repository
contains pod volume backups for.
type: string
required:
Expand All @@ -62,7 +62,7 @@ spec:
- volumeNamespace
type: object
status:
description: ResticRepositoryStatus is the current status of a ResticRepository.
description: BackupRepositoryStatus is the current status of a BackupRepository.
properties:
lastMaintenanceTime:
description: LastMaintenanceTime is the last time maintenance was
Expand All @@ -72,10 +72,10 @@ spec:
type: string
message:
description: Message is a message about the current status of the
ResticRepository.
BackupRepository.
type: string
phase:
description: Phase is the current state of the ResticRepository.
description: Phase is the current state of the BackupRepository.
enum:
- New
- Ready
Expand Down
20 changes: 16 additions & 4 deletions config/crd/v1/bases/velero.io_podvolumebackups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ spec:
jsonPath: .spec.volume
name: Volume
type: string
- description: Restic repository identifier for this backup
- description: Backup repository identifier for this backup
jsonPath: .spec.repoIdentifier
name: Restic Repo
name: Repository ID
type: string
- description: The type of the uploader to handle data transfer
jsonPath: .spec.uploader-type
name: Uploader Type
type: string
- description: Name of the Backup Storage Location where this backup should be
stored
Expand Down Expand Up @@ -70,7 +74,7 @@ spec:
properties:
backupStorageLocation:
description: BackupStorageLocation is the name of the backup storage
location where the restic repository is stored.
location where the backup repository is stored.
type: string
node:
description: Node is the name of the node that the Pod is running
Expand Down Expand Up @@ -114,14 +118,22 @@ spec:
type: string
type: object
repoIdentifier:
description: RepoIdentifier is the restic repository identifier.
description: RepoIdentifier is the backup repository identifier.
type: string
tags:
additionalProperties:
type: string
description: Tags are a map of key-value pairs that should be applied
to the volume backup as tags.
type: object
uploader-type:
description: UploaderType is the type of the uploader to handle the
data transfer.
enum:
- kopia
- restic
- ""
type: string
volume:
description: Volume is the name of the volume within the Pod to be
backed up.
Expand Down
16 changes: 14 additions & 2 deletions config/crd/v1/bases/velero.io_podvolumerestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
jsonPath: .spec.pod.name
name: Pod
type: string
- description: The type of the uploader to handle data transfer
jsonPath: .spec.uploader-type
name: Uploader Type
type: string
- description: Name of the volume to be restored
jsonPath: .spec.volume
name: Volume
Expand Down Expand Up @@ -67,7 +71,7 @@ spec:
properties:
backupStorageLocation:
description: BackupStorageLocation is the name of the backup storage
location where the restic repository is stored.
location where the backup repository is stored.
type: string
pod:
description: Pod is a reference to the pod containing the volume to
Expand Down Expand Up @@ -107,11 +111,19 @@ spec:
type: string
type: object
repoIdentifier:
description: RepoIdentifier is the restic repository identifier.
description: RepoIdentifier is the backup repository identifier.
type: string
snapshotID:
description: SnapshotID is the ID of the volume snapshot to be restored.
type: string
uploader-type:
description: UploaderType is the type of the uploader to handle the
data transfer.
enum:
- kopia
- restic
- ""
type: string
volume:
description: Volume is the name of the volume within the Pod to be
restored.
Expand Down
6 changes: 3 additions & 3 deletions config/crd/v1/crds/crds.go

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ rules:
- apiGroups:
- velero.io
resources:
- backups
verbs:
- create
- delete
- apiGroups:
- velero.io
resources:
- backupstoragelocations
- backuprepositories
verbs:
- create
- delete
Expand All @@ -46,15 +39,22 @@ rules:
- apiGroups:
- velero.io
resources:
- backupstoragelocations/status
- backuprepositories/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- deletebackuprequests
- backups
verbs:
- create
- delete
- apiGroups:
- velero.io
resources:
- backupstoragelocations
verbs:
- create
- delete
Expand All @@ -66,15 +66,15 @@ rules:
- apiGroups:
- velero.io
resources:
- deletebackuprequests/status
- backupstoragelocations/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- downloadrequests
- deletebackuprequests
verbs:
- create
- delete
Expand All @@ -86,15 +86,15 @@ rules:
- apiGroups:
- velero.io
resources:
- downloadrequests/status
- deletebackuprequests/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- podvolumebackups
- downloadrequests
verbs:
- create
- delete
Expand All @@ -106,15 +106,15 @@ rules:
- apiGroups:
- velero.io
resources:
- podvolumebackups/status
- downloadrequests/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- podvolumerestores
- podvolumebackups
verbs:
- create
- delete
Expand All @@ -126,15 +126,15 @@ rules:
- apiGroups:
- velero.io
resources:
- podvolumerestores/status
- podvolumebackups/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- resticrepositories
- podvolumerestores
verbs:
- create
- delete
Expand All @@ -146,7 +146,7 @@ rules:
- apiGroups:
- velero.io
resources:
- resticrepositories/status
- podvolumerestores/status
verbs:
- get
- patch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,41 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ResticRepositorySpec is the specification for a ResticRepository.
type ResticRepositorySpec struct {
// VolumeNamespace is the namespace this restic repository contains
// BackupRepositorySpec is the specification for a BackupRepository.
type BackupRepositorySpec struct {
// VolumeNamespace is the namespace this backup repository contains
// pod volume backups for.
VolumeNamespace string `json:"volumeNamespace"`

// BackupStorageLocation is the name of the BackupStorageLocation
// that should contain this repository.
BackupStorageLocation string `json:"backupStorageLocation"`

// ResticIdentifier is the full restic-compatible string for identifying
// ResticIdentifier is the full backup-compatible string for identifying
// this repository.
ResticIdentifier string `json:"resticIdentifier"`

// MaintenanceFrequency is how often maintenance should be run.
MaintenanceFrequency metav1.Duration `json:"maintenanceFrequency"`
}

// ResticRepositoryPhase represents the lifecycle phase of a ResticRepository.
// BackupRepositoryPhase represents the lifecycle phase of a BackupRepository.
// +kubebuilder:validation:Enum=New;Ready;NotReady
type ResticRepositoryPhase string
type BackupRepositoryPhase string

const (
ResticRepositoryPhaseNew ResticRepositoryPhase = "New"
ResticRepositoryPhaseReady ResticRepositoryPhase = "Ready"
ResticRepositoryPhaseNotReady ResticRepositoryPhase = "NotReady"
BackupRepositoryPhaseNew BackupRepositoryPhase = "New"
BackupRepositoryPhaseReady BackupRepositoryPhase = "Ready"
BackupRepositoryPhaseNotReady BackupRepositoryPhase = "NotReady"
)

// ResticRepositoryStatus is the current status of a ResticRepository.
type ResticRepositoryStatus struct {
// Phase is the current state of the ResticRepository.
// BackupRepositoryStatus is the current status of a BackupRepository.
type BackupRepositoryStatus struct {
// Phase is the current state of the BackupRepository.
// +optional
Phase ResticRepositoryPhase `json:"phase,omitempty"`
Phase BackupRepositoryPhase `json:"phase,omitempty"`

// Message is a message about the current status of the ResticRepository.
// Message is a message about the current status of the BackupRepository.
// +optional
Message string `json:"message,omitempty"`

Expand All @@ -73,32 +73,32 @@ type ResticRepositoryStatus struct {
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

type ResticRepository struct {
type BackupRepository struct {
metav1.TypeMeta `json:",inline"`

// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// +optional
Spec ResticRepositorySpec `json:"spec,omitempty"`
Spec BackupRepositorySpec `json:"spec,omitempty"`

// +optional
Status ResticRepositoryStatus `json:"status,omitempty"`
Status BackupRepositoryStatus `json:"status,omitempty"`
}

// TODO(2.0) After converting all resources to use the runtime-controller client,
// the k8s:deepcopy marker will no longer be needed and should be removed.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:rbac:groups=velero.io,resources=resticrepositories,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=velero.io,resources=resticrepositories/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=velero.io,resources=backuprepositories,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=velero.io,resources=backuprepositories/status,verbs=get;update;patch

// ResticRepositoryList is a list of ResticRepositories.
type ResticRepositoryList struct {
// BackupRepositoryList is a list of BackupRepositories.
type BackupRepositoryList struct {
metav1.TypeMeta `json:",inline"`

// +optional
metav1.ListMeta `json:"metadata,omitempty"`

Items []ResticRepository `json:"items"`
Items []BackupRepository `json:"items"`
}
Loading

0 comments on commit a422c9c

Please sign in to comment.