Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Sync from open-cluster-management-io/policy-collection: #457 #48

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ spec:

### Created by the ACM user

#### acm-hub-pvc-backup-config
#### hub-pvc-backup


- Created by the user on the backup hub.
Expand All @@ -125,7 +125,7 @@ spec:
kind: ConfigMap
apiVersion: v1
metadata:
name: acm-hub-pvc-backup-config
name: hub-pvc-backup
namespace: open-cluster-management-backup
labels:
cluster.open-cluster-management.io/backup: cluster-activation
Expand All @@ -141,15 +141,15 @@ data:
```

The above ConfigMap defines global options for all hub PVCs that need to be backed up with the policy. If you want to provide custom
properties for a PVC, you should define a ConfigMap using this name convention : `acm-hub-pvc-backup-config-<pvc-ns>-<pvc-name>`
properties for a PVC, you should define a ConfigMap using this name convention : `hub-pvc-backup-<pvc-ns>-<pvc-name>`

For example, if the PVC `my-pvc` created in namespace `ns-1` should be backed up every 5 hours, create this ConfigMap under the `open-cluster-management-backup` namespace :

```yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: acm-hub-pvc-backup-config-ns-1-my-pvc
name: hub-pvc-backup-ns-1-my-pvc
namespace: open-cluster-management-backup
labels:
cluster.open-cluster-management.io/backup: cluster-activation
Expand Down Expand Up @@ -191,7 +191,7 @@ type: Opaque

### Generated by the policy

#### acm-hub-pvc-backup-config-info-<pvc_name>
#### hub-pvc-backup-<pvc_name>

Created by the volsync policy on the backup hub for each PVC using the PVC's settings
This resource is backed up and used by the volsync ReplicationDestination to recreate the PV on the restore hub.
Expand All @@ -200,7 +200,7 @@ This resource is backed up and used by the volsync ReplicationDestination to rec
kind: ConfigMap
apiVersion: v1
metadata:
name: acm-hub-pvc-backup-config-info-mongo-storage
name: hub-pvc-backup-mongo-storage
namespace: pacman-ns
labels:
cluster.open-cluster-management.io/backup: cluster-activation
Expand All @@ -212,18 +212,18 @@ data:
```


#### acm-hub-pvc-backup-config-pvcs
#### hub-pvc-backup-pvcs

Created by the policy on the backup hub; lists all PVCs that need to be restored. This resource is backed up

```yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: acm-hub-pvc-backup-config-pvcs
name: hub-pvc-backup-pvcs
namespace: open-cluster-management-backup
labels:
app: acm-hub-pvc-backup-config-pvcs
app: hub-pvc-backup-pvcs
cluster.open-cluster-management.io/backup: cluster-activation
data:
pvcs: 'pacman-restore#mongo-storage##pacman-vb#mongo-storage##pacman#mongo-storage'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The acm-hub-pvc-backup-config ConfigMap and secret must be defined under the open-cluster-management-backup ns,
# if a BackupSchedule is running and there are PVCs with the volsync label.
# The hub-pvc-backup ConfigMap and acm-hub-pvc-backup-restic-secret Secret must be defined under the open-cluster-management-backup ns,
# when a BackupSchedule is running and there are PVCs with the cluster.open-cluster-management.io/backup-hub-pvc label.
# The volsync ConfigMap is in this format:
##
#kind: ConfigMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
{{- $ns := "open-cluster-management-backup" }}
{{- $volsync_secret := "acm-hub-pvc-backup-restic-secret" }}

{{- /* common volsync config; to define different config for a PVC, create a acm-hub-pvc-backup-config-pvc-ns-pvcname configMap */ -}}
{{- /* common volsync config; to define different config for a PVC, create a hub-pvc-backup-pvc-ns-pvcname configMap */ -}}
{{- $volsync_map := "hub-pvc-backup" }}
{{- $volsync_label := "cluster.open-cluster-management.io/backup-hub-pvc" }}

Expand All @@ -41,7 +41,7 @@ spec:
{{- $volsync_pvcs := "hub-pvc-backup-pvcs" }}

{{- /* Create the volsync ReplicationDestination and secret - if Restore exists, PVC is created by a Restore and no Backup is running */ -}}
{{- /* Use the hub-pvc-backup-pvcs-pvcns-pvcname config instead of the default acm-hub-pvc-backup-config map, if such map exists under the $ns */ -}}
{{- /* Use the hub-pvc-backup-pvcs-pvcns-pvcname config instead of the default hub-pvc-backup-pvcs map, if such map exists under the $ns */ -}}

{{- /* hub-pvc-backup-pvcs map should exist and have a backup-name label */ -}}
{{- $volsync_pvcs_map := lookup "v1" "ConfigMap" $ns $volsync_pvcs }}
Expand Down Expand Up @@ -194,7 +194,7 @@ spec:
{{- $schedule_label := "cluster.open-cluster-management.io/backup-schedule-type, cluster.open-cluster-management.io/backup-schedule-type in (resources)"}}
{{- $volsync_backup_cond := gt (len ( lookup $velero_api $kind_schedule $ns "" $schedule_label).items ) 0 }}

{{- /* acm-hub-pvc-backup-config-pvcs map should exist */ -}}
{{- /* hub-pvc-backup-pvcs map should exist */ -}}
{{- $volsync_pvcs := "hub-pvc-backup-pvcs" }}
{{- $volsync_pvcs_map := lookup "v1" "ConfigMap" $ns $volsync_pvcs }}
{{- $volsync_restore_cond := eq $volsync_pvcs_map.metadata.name $volsync_pvcs }}
Expand Down Expand Up @@ -236,7 +236,7 @@ spec:
{{- $schedule_label := "cluster.open-cluster-management.io/backup-schedule-type, cluster.open-cluster-management.io/backup-schedule-type in (resources)"}}
{{- $volsync_backup_cond := gt (len ( lookup $velero_api $kind_schedule $ns "" $schedule_label).items ) 0 }}
{{- $volsync_label := "cluster.open-cluster-management.io/backup-hub-pvc" }}
{{- /* acm-hub-pvc-backup-config-pvcs map should exist */ -}}
{{- /* hub-pvc-backup-pvcs map should exist */ -}}
{{- $volsync_pvcs := "hub-pvc-backup-pvcs" }}
{{- $volsync_pvcs_map := lookup "v1" "ConfigMap" $ns $volsync_pvcs }}
{{- $volsync_restore_cond := eq $volsync_pvcs_map.metadata.name $volsync_pvcs }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
{{- range $pvc := (lookup "v1" "PersistentVolumeClaim" "" "" $volsync_label).items }}

{{- if eq $pvc.status.phase "Bound" }}
{{- /* Use the hub-pvc-backup-pvcns-pvcname config instead of the default acm-hub-pvc-backup-config map, if such map exists under the $ns */ -}}
{{- /* Use the hub-pvc-backup-pvcns-pvcname config instead of the default hub-pvc-backup map, if such map exists under the $ns */ -}}
{{- $pvc_config_name := ( (cat $volsync_map "-" $pvc.metadata.namespace "-" $pvc.metadata.name ) | replace " " "" ) }}

{{- $pvc_config_info_name := ( (cat $volsync_map "-" $pvc.metadata.name ) | replace " " "" ) }}
Expand Down