Skip to content

Commit

Permalink
add annotation to exclude a PVC directly from backup monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
foosinn committed Oct 14, 2021
1 parent 74999b7 commit 8603143
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ spec:
backup.velero.io/backup-volumes-excludes: tmp
```

## Example PVC config

To exclude a PVC that is not in use from backups annotate it as follows:

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
backup.velero.io/backup-excluded: "true"
```
## Example Alertmanager config
```
Expand Down
1 change: 1 addition & 0 deletions watcher/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
const (
BackupAnnotation = "backup.velero.io/backup-volumes"
ExcludeAnnotation = "backup.velero.io/backup-volumes-excludes"
ExcludePVCAnnotation = "backup.velero.io/backup-excluded"
)

func listPodHandledPVCs(pod *v1.Pod, handledPvcNames *map[string]interface{}) {
Expand Down
4 changes: 4 additions & 0 deletions watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (w *Watcher) Update(namespace string) []PVCInfo {
return nil
}
for _, pvc := range pvcList {
annotations := pvc.GetAnnotations()
if v, ok := annotations[ExcludePVCAnnotation]; ok && v == "true" {
continue
}
pvcName := pvc.GetName()
if _, ok := handledPVCs[pvcName]; !ok {
missing = append(missing, PVCInfo{
Expand Down

0 comments on commit 8603143

Please sign in to comment.