From b4c3cb505a403b3da2aa1ee7af644e1476c071a8 Mon Sep 17 00:00:00 2001 From: asagarwal Date: Mon, 15 Jan 2024 18:50:05 +0530 Subject: [PATCH] Handle conflicts b/w data protection at cluster and cluster-group level Signed-off-by: Astha Agarwal --- docs/data-sources/backup_schedule.md | 69 ++- .../tanzu-mission-control_data_protection.md | 10 +- docs/resources/backup_schedule.md | 553 +++++------------- docs/resources/enable_data_protection.md | 10 +- .../resource_backup_schedule.go | 22 +- internal/resources/common/scope/constants.go | 1 + .../resource_enable_data_protection.go | 14 + .../data-sources/backup_schedule.md.tmpl | 14 +- ...zu-mission-control_data_protection.md.tmpl | 10 +- templates/resources/backup_schedule.md.tmpl | 30 +- .../resources/enable_data_protection.md.tmpl | 10 +- 11 files changed, 294 insertions(+), 449 deletions(-) diff --git a/docs/data-sources/backup_schedule.md b/docs/data-sources/backup_schedule.md index 47bccee33..0961c2ff8 100644 --- a/docs/data-sources/backup_schedule.md +++ b/docs/data-sources/backup_schedule.md @@ -14,7 +14,7 @@ Listing backup schedules by cluster or cluster group scope is supported only for ```terraform data "tanzu-mission-control_backup_schedule" "demo" { - name = "BACKUP_SCHEDULE_NAME" + name = "BACKUP_SCHEDULE_NAME" scope { cluster { management_cluster_name = "MGMT_CLS_NAME" @@ -34,10 +34,10 @@ data "tanzu-mission-control_backup_schedule" "demo" { ```terraform data "tanzu-mission-control_backup_schedule" "demo" { - name = "BACKUP_SCHEDULE_NAME" + name = "BACKUP_SCHEDULE_NAME" scope { cluster_group { - cluster_group_name = "CG_NAME" + cluster_group_name = "CG_NAME" } } @@ -52,13 +52,13 @@ data "tanzu-mission-control_backup_schedule" "demo" { ### Required -- `name` (String) The name of the backup schedule - `scope` (Block List, Min: 1, Max: 1) Search scope block (see [below for nested schema](#nestedblock--scope)) ### Optional - `include_total_count` (Boolean) Whether to include total count of backups. (Default: True) +- `name` (String) The name of the backup schedule - `query` (String) Define a query for listing backups - `sort_by` (String) Sort backups by field. @@ -74,7 +74,7 @@ data "tanzu-mission-control_backup_schedule" "demo" { Optional: - `cluster` (Block List, Max: 1) Cluster scope block (see [below for nested schema](#nestedblock--scope--cluster)) -- `cluster_group` (Block List, Max: 1) The schema for cluster group full name (see [below for nested schema](#nestedblock--scope--cluster_group)) +- `cluster_group` (Block List, Max: 1) Cluster group scope block (see [below for nested schema](#nestedblock--scope--cluster_group)) ### Nested Schema for `scope.cluster` @@ -82,15 +82,20 @@ Optional: Required: - `cluster_name` (String) Cluster name + +Optional: + - `management_cluster_name` (String) Management cluster name - `provisioner_name` (String) Cluster provisioner name + ### Nested Schema for `scope.cluster_group` Required: -- `cluster_group_name` (String) Name of the cluster group +- `cluster_group_name` (String) Cluster group name + @@ -102,6 +107,7 @@ Read-Only: - `meta` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--meta)) - `name` (String) - `scope` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--scope)) +- `selector` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--selector)) - `spec` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--spec)) @@ -122,7 +128,7 @@ Read-Only: Read-Only: - `cluster` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--scope--cluster)) -- `cluster_group` (Block List, Max: 1) The schema for cluster group full name (see [below for nested schema](#nestedblock--scope--cluster_group)) +- `cluster_group` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--scope--cluster_group)) ### Nested Schema for `schedules.scope.cluster` @@ -133,12 +139,43 @@ Read-Only: - `management_cluster_name` (String) - `provisioner_name` (String) - -### Nested Schema for `scope.cluster_group` -Required: + +### Nested Schema for `schedules.scope.cluster_group` + +Read-Only: + +- `cluster_group_name` (String) + + + + +### Nested Schema for `schedules.selector` + +Read-Only: + +- `excluded_names` (List of String) +- `label_selector` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--selector--label_selector)) +- `names` (List of String) + + +### Nested Schema for `schedules.selector.label_selector` + +Read-Only: + +- `match_expression` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--selector--label_selector--match_expression)) +- `match_labels` (Map of String) + + +### Nested Schema for `schedules.selector.label_selector.match_labels` + +Read-Only: + +- `key` (String) +- `operator` (String) +- `values` (List of String) + -- `cluster_group_name` (String) Name of the cluster group @@ -167,24 +204,24 @@ Read-Only: - `csi_snapshot_timeout` (String) - `default_volumes_to_fs_backup` (Boolean) - `default_volumes_to_restic` (Boolean) +- `excluded_cluster_scoped_resources` (List of String) +- `excluded_namespace_scoped_resources` (List of String) - `excluded_namespaces` (List of String) - `excluded_resources` (List of String) - `hooks` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--spec--template--hooks)) - `include_cluster_resources` (Boolean) +- `included_cluster_scoped_resources` (List of String) +- `included_namespace_scoped_resources` (List of String) - `included_namespaces` (List of String) - `included_resources` (List of String) - `label_selector` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--spec--template--label_selector)) - `or_label_selector` (List of Object) (see [below for nested schema](#nestedobjatt--schedules--spec--template--or_label_selector)) - `ordered_resources` (Map of String) +- `snapshot_move_data` (Boolean) - `snapshot_volumes` (Boolean) - `storage_location` (String) - `sys_excluded_namespaces` (List of String) - `volume_snapshot_locations` (List of String) -- `included_cluster_scoped_resources` (List of String) -- `excluded_cluster_scoped_resources` (List of String) -- `included_namespace_scoped_resources` (List of String) -- `excluded_namespace_scoped_resources` (List of String) -- `snapshot_move_data` (Boolean) ### Nested Schema for `schedules.spec.template.volume_snapshot_locations` diff --git a/docs/guides/tanzu-mission-control_data_protection.md b/docs/guides/tanzu-mission-control_data_protection.md index fd298cab8..1f90f0141 100644 --- a/docs/guides/tanzu-mission-control_data_protection.md +++ b/docs/guides/tanzu-mission-control_data_protection.md @@ -1,13 +1,16 @@ --- Title: "Data Protection of a Tanzu Kubernetes Cluster" Description: |- - An example of using Data Protection Feature for a Tanzu Kubernetes Cluster + An example of using Data Protection Feature for a Tanzu Kubernetes Cluster/Cluster Group --- # Enable Data Protection The `tanzu-mission-control_enable_data_protection` resource enables users to activate and set up data protection for a Tanzu Kubernetes Cluster. Once enabled, users can create instant backups or schedule backups for later. +**NOTE :** To resolve cluster and cluster group data protection conflicts use the below command +``terraform refresh`` + For more information regarding data protection, see [Data Protection][data-protection]. [data-protection]: https://docs.vmware.com/en/VMware-Tanzu-Mission-Control/services/tanzumc-concepts/GUID-C16557BC-EB1B-4414-8E63-28AD92E0CAE5.html @@ -26,7 +29,10 @@ For more information regarding target location, see [Target Location][target-loc # Backup Schedule -The `tanzu-mission-control_backup_schedule` resource enables users to create and configure scheduled backups in a cluster. +The `tanzu-mission-control_backup_schedule` resource enables users to create and configure scheduled backups in a cluster/cluster-group. + +NOTE : To resolve cluster and cluster group backup schedule conflicts use the below command +``terraform refresh`` Backups can be applied in 3 levels: diff --git a/docs/resources/backup_schedule.md b/docs/resources/backup_schedule.md index 5f18549b7..d54b4e897 100644 --- a/docs/resources/backup_schedule.md +++ b/docs/resources/backup_schedule.md @@ -17,13 +17,19 @@ For more information regarding scheduled backups, see [Scheduled Backups][backup [backup-schedule]: https://docs.vmware.com/en/VMware-Tanzu-Mission-Control/services/tanzumc-using/GUID-89926F80-050A-4F1C-9D04-D56D5F453995.html?hWord=N4IghgNiBcIEZgMYGsCuAHABAZ0QCwFMATVCAkAXyA +**NOTE :** To resolve cluster and cluster group backup schedule conflicts use the below command +``terraform refresh`` + +For instance, in case cluster group/cluster data protection is disabled then use above command +and remove cluster group/cluster backup schedule resource from terraform file. + # Entire Cluster Weekly Backup Schedule ## Example Usage ```terraform resource "tanzu-mission-control_backup_schedule" "sample-full" { - name = "full-weekly" + name = "full-weekly" scope { cluster { management_cluster_name = "MGMT_CLS_NAME" @@ -58,13 +64,14 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } ``` + # Selected Namespaces Hourly Backup Schedule ## Example Usage ```terraform resource "tanzu-mission-control_backup_schedule" "sample-full" { - name = "namespaces-hourly" + name = "namespaces-hourly" scope { cluster { management_cluster_name = "MGMT_CLS_NAME" @@ -73,7 +80,7 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } } - backup_scope = "SET_NAMESPACES" + backup_scope = "SET_NAMESPACES" spec { schedule { @@ -149,7 +156,7 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { ```terraform resource "tanzu-mission-control_backup_schedule" "sample-full" { - name = "label-based-no-storage" + name = "label-based-no-storage" scope { cluster { management_cluster_name = "MGMT_CLS_NAME" @@ -158,7 +165,7 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } } - backup_scope = "LABEL_SELECTOR" + backup_scope = "LABEL_SELECTOR" spec { @@ -188,330 +195,34 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } ``` -## Import Backup Schedule -The resource ID for importing an existing backup schedule should be comprised of a full cluster name and a backup schedule name separated by '/'. - -```bash -terraform import tanzu-mission-control_backup_schedule.demo_backup MANAGEMENT_CLUSTER_NAME/PROVISIONER_NAME/CLUSTER_NAME/BACKUP_SCHEDULE_NAME -``` - - -## Schema - -### Required - -- `backup_scope` (String) Scope for backup schedule. -Valid values are (FULL_CLUSTER, SET_NAMESPACES, LABEL_SELECTOR) -- `name` (String) The name of the backup schedule -- `scope` (Block List, Min: 1, Max: 1) Scope block for Back up schedule (cluster/cluster group) (see [below for nested schema](#nestedblock--scope)) -- `spec` (Block List, Min: 1, Max: 1) Backup schedule spec block (see [below for nested schema](#nestedblock--spec)) - -### Optional - -- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta)) - -### Read-Only - -- `id` (String) The ID of this resource. - - -### Nested Schema for `scope` - -Optional: - -- `cluster` (Block List, Max: 1) Cluster scope block (see [below for nested schema](#nestedblock--scope--cluster)) - - -### Nested Schema for `scope.cluster` - -Required: - -- `cluster_name` (String) Cluster name -- `management_cluster_name` (String) Management cluster name -- `provisioner_name` (String) Cluster provisioner name - - - - -### Nested Schema for `spec` - -Required: - -- `schedule` (Block List, Min: 1, Max: 1) Schedule block (see [below for nested schema](#nestedblock--spec--schedule)) - -Optional: - -- `paused` (Boolean) Paused specifies whether the schedule is paused or not. (Default: False) -- `template` (Block List, Max: 1) Backup schedule template block, backup definition to be run on the provided schedule (see [below for nested schema](#nestedblock--spec--template)) - - -### Nested Schema for `spec.schedule` - -Required: - -- `rate` (String) Cron expression of backup schedule rate/interval - - - -### Nested Schema for `spec.template` - -Optional: - -- `backup_ttl` (String) The backup retention period. -- `csi_snapshot_timeout` (String) Specifies the time used to wait for CSI VolumeSnapshot status turns to ReadyToUse during creation, before returning error as timeout. -The default value is 10 minute. -Format is the time number and time sign, example: "50s" (50 seconds) -- `default_volumes_to_fs_backup` (Boolean) Specifies whether all pod volumes should be backed up via file system backup by default. -(Default: True) -- `default_volumes_to_restic` (Boolean) Specifies whether restic should be used to take a backup of all pod volumes by default. -(Default: False) -- `excluded_namespaces` (List of String) The namespaces to be excluded in the backup. -Can't be used if scope is SET_NAMESPACES. -- `excluded_resources` (List of String) The name list for the resources to be excluded in backup. -- `hooks` (Block List, Max: 1) Hooks block represent custom actions that should be executed at different phases of the backup. (see [below for nested schema](#nestedblock--spec--template--hooks)) -- `include_cluster_resources` (Boolean) A flag which specifies whether cluster-scoped resources should be included for consideration in the backup. -If set to true, all cluster-scoped resources will be backed up. If set to false, all cluster-scoped resources will be excluded from the backup. -If unset, all cluster-scoped resources are included if and only if all namespaces are included and there are no excluded namespaces. -Otherwise, only cluster-scoped resources associated with namespace-scoped resources included in the backup spec are backed up. -For example, if a PersistentVolumeClaim is included in the backup, its associated PersistentVolume (which is cluster-scoped) would also be backed up. -(Default: False) -- `included_namespaces` (List of String) The namespace to be included for backup from. -If empty, all namespaces are included. -Can't be used if scope is FULL_CLUSTER. -Required if scope is SET_NAMESPACES. -- `included_resources` (List of String) The name list for the resources to be included into backup. If empty, all resources are included. -- `label_selector` (Block List, Max: 1) The label selector to selectively adding individual objects to the backup schedule. -If not specified, all objects are included. -Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. -Required if scope is LABEL_SELECTOR and Or Label Selectors are not defined (see [below for nested schema](#nestedblock--spec--template--label_selector)) -- `or_label_selector` (Block List) (Repeatable Block) A list of label selectors to filter with when adding individual objects to the backup. -If multiple provided they will be joined by the OR operator. -LabelSelector as well as OrLabelSelectors cannot co-exist in backup request, only one of them can be used. -Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. -Required if scope is LABEL_SELECTOR and Label Selector is not defined (see [below for nested schema](#nestedblock--spec--template--or_label_selector)) -- `ordered_resources` (Map of String) Specifies the backup order of resources of specific Kind. The map key is the Kind name and value is a list of resource names separated by commas. -Each resource name has format "namespace/resourcename". -For cluster resources, simply use "resourcename". -- `snapshot_volumes` (Boolean) A flag which specifies whether to take cloud snapshots of any PV's referenced in the set of objects included in the Backup. -If set to true, snapshots will be taken, otherwise, snapshots will be skipped. -If left unset, snapshots will be attempted if volume snapshots are configured for the cluster. -- `storage_location` (String) The name of a BackupStorageLocation where the backup should be stored. -- `volume_snapshot_locations` (List of String) A list containing names of VolumeSnapshotLocations associated with this backup. -- `included_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to include in the backup. -If set to "*", all cluster-scoped resource types are included. The default value is empty, which means only related cluster-scoped resources are included. -- `excluded_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to exclude from the backup. If set to "*", all cluster-scoped resource types are excluded. -- `included_namespace_scoped_resources` (List of String) List of namespace-scoped resource type names to include in the backup. -The default value is "*". -- `excluded_namespace_scoped_resources` (List of String) List of namespace-scoped resource type names to exclude from the backup. -If set to "*", all namespace-scoped resource types are excluded. - -Read-Only: - -- `sys_excluded_namespaces` (List of String) System excluded namespaces for state. - - -### Nested Schema for `spec.template.hooks` - -Optional: - -- `resource` (Block List) (Repeatable Block) Resources are hooks that should be executed when backing up individual instances of a resource. (see [below for nested schema](#nestedblock--spec--template--hooks--resource)) - - -### Nested Schema for `spec.template.hooks.resource` - -Required: - -- `name` (String) The name of the hook resource. - -Optional: -- `excluded_namespaces` (List of String) Specifies the namespaces to which this hook spec does not apply. -- `included_namespaces` (List of String) Specifies the namespaces to which this hook spec applies. -If empty, it applies to all namespaces. -- `label_selector` (Block List, Max: 1) The label selector to selectively adding individual objects to the hook resource. -If not specified, all objects are included. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--label_selector)) -- `post_hook` (Block List) (Repeatable Block) A list of backup hooks to execute after storing the item in the backup. -These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--post_hook)) -- `pre_hook` (Block List) (Repeatable Block) A list of backup hooks to execute after storing the item in the backup. -These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--pre_hook)) - - -### Nested Schema for `spec.template.hooks.resource.label_selector` - -Optional: - -- `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--label_selector--match_expression)) -- `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". -The requirements are ANDed. - - -### Nested Schema for `spec.template.hooks.resource.label_selector.match_expression` - -Required: - -- `key` (String) Key is the label key that the selector applies to. -- `operator` (String) Operator represents a key's relationship to a set of values. -Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". - -Optional: - -- `values` (List of String) Values is an array of string values. -If the operator is "In" or "NotIn", the values array must be non-empty. -If the operator is "Exists" or "DoesNotExist", the values array must be empty. -This array is replaced during a strategic merge patch. - - - - -### Nested Schema for `spec.template.hooks.resource.post_hook` - -Required: - -- `exec` (Block List, Min: 1, Max: 1) Exec block defines an exec hook. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--post_hook--exec)) - - -### Nested Schema for `spec.template.hooks.resource.post_hook.exec` - -Required: - -- `command` (List of String) The command and arguments to execute. -- `container` (String) The container in the pod where the command should be executed. -If not specified, the pod's first container is used. - -Optional: - -- `on_error` (String) Specifies how Velero should behave if it encounters an error executing this hook. -Valid values are (FAIL, CONTINUE) -- `timeout` (String) Defines the maximum amount of time Velero should wait for the hook to complete before considering the execution a failure. - - - - -### Nested Schema for `spec.template.hooks.resource.pre_hook` - -Required: - -- `exec` (Block List, Min: 1, Max: 1) Exec block defines an exec hook. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--pre_hook--exec)) - - -### Nested Schema for `spec.template.hooks.resource.pre_hook.exec` - -Required: - -- `command` (List of String) The command and arguments to execute. -- `container` (String) The container in the pod where the command should be executed. -If not specified, the pod's first container is used. - -Optional: - -- `on_error` (String) Specifies how Velero should behave if it encounters an error executing this hook. -Valid values are (FAIL, CONTINUE) -- `timeout` (String) Defines the maximum amount of time Velero should wait for the hook to complete before considering the execution a failure. - - - - - - -### Nested Schema for `spec.template.label_selector` - -Optional: - -- `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--label_selector--match_expression)) -- `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". -The requirements are ANDed. - - -### Nested Schema for `spec.template.label_selector.match_expression` - -Required: - -- `key` (String) Key is the label key that the selector applies to. -- `operator` (String) Operator represents a key's relationship to a set of values. -Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". - -Optional: - -- `values` (List of String) Values is an array of string values. -If the operator is "In" or "NotIn", the values array must be non-empty. -If the operator is "Exists" or "DoesNotExist", the values array must be empty. -This array is replaced during a strategic merge patch. - - - - -### Nested Schema for `spec.template.or_label_selector` - -Optional: - -- `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--or_label_selector--match_expression)) -- `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". -The requirements are ANDed. - - -### Nested Schema for `spec.template.or_label_selector.match_expression` - -Required: - -- `key` (String) Key is the label key that the selector applies to. -- `operator` (String) Operator represents a key's relationship to a set of values. -Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". - -Optional: - -- `values` (List of String) Values is an array of string values. -If the operator is "In" or "NotIn", the values array must be non-empty. -If the operator is "Exists" or "DoesNotExist", the values array must be empty. -This array is replaced during a strategic merge patch. - - - - - - -### Nested Schema for `meta` - -Optional: - -- `annotations` (Map of String) Annotations for the resource -- `description` (String) Description of the resource -- `labels` (Map of String) Labels for the resource - -Read-Only: - -- `resource_version` (String) Resource version of the resource -- `uid` (String) UID of the resource - - -# Entire ClusterGroup Weekly Backup Schedule +# Entire Cluster Group Weekly Backup Schedule ## Example Usage ```terraform resource "tanzu-mission-control_backup_schedule" "sample-full" { - name = "full-weekly" + name = "full-weekly" scope { cluster_group { - cluster_group_name = "CG_NAME" + cluster_group_name = "CG_NAME" } } + selector { + names = [ + "cluster1", + "cluster2" + ] + } backup_scope = "FULL_CLUSTER" - - selector{ - excluded_names = [ - "cluster1", - "cluster2" - ] - } - spec { schedule { rate = "0 12 * * 1" } template { - backup_ttl = "2592000s" + backup_ttl = "2592000s" excluded_namespaces = [ "app-01", "app-02", @@ -529,28 +240,28 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } ``` + # Selected Namespaces Hourly Cluster Group Backup Schedule ## Example Usage ```terraform resource "tanzu-mission-control_backup_schedule" "sample-full" { - name = "namespaces-hourly" + name = "namespaces-hourly" scope { cluster_group { - cluster_group_name = "CG_NAME" + cluster_group_name = "CG_NAME" } } - - backup_scope = "SET_NAMESPACES" - - selector{ - excluded_names = [ + selector { + names = [ "cluster1", "cluster2" ] } + backup_scope = "SET_NAMESPACES" + spec { schedule { rate = "30 * * * *" @@ -631,14 +342,15 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { cluster_group_name = "CG_NAME" } } - - backup_scope = "LABEL_SELECTOR" selector { - excluded_names = [ + names = [ "cluster1", "cluster2" ] } + backup_scope = "LABEL_SELECTOR" + + spec { schedule { rate = "0 12 * * *" @@ -666,21 +378,28 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { } ``` +## Import Backup Schedule +The resource ID for importing an existing backup schedule should be comprised of a full cluster name and a backup schedule name separated by '/'. + +```bash +terraform import tanzu-mission-control_backup_schedule.demo_backup MANAGEMENT_CLUSTER_NAME/PROVISIONER_NAME/CLUSTER_NAME/BACKUP_SCHEDULE_NAME +``` + ## Schema ### Required -- `name` (String) The name of the backup schedule - `backup_scope` (String) Scope for backup schedule. - Valid values are (FULL_CLUSTER, SET_NAMESPACES, LABEL_SELECTOR) +Valid values are (FULL_CLUSTER, SET_NAMESPACES, LABEL_SELECTOR) +- `name` (String) The name of the backup schedule - `scope` (Block List, Min: 1, Max: 1) Scope block for Back up schedule (cluster/cluster group) (see [below for nested schema](#nestedblock--scope)) - `spec` (Block List, Min: 1, Max: 1) Backup schedule spec block (see [below for nested schema](#nestedblock--spec)) ### Optional - `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta)) -- `selector` (Block List, Max: 1) A selector to include/exclude specific clusters in a cluster group (optional) (see [below for nested schema](#nestedblock--selector)) +- `selector` (Block List) Selector of the cluster group backup schedule (see [below for nested schema](#nestedblock--selector)) ### Read-Only @@ -692,7 +411,7 @@ resource "tanzu-mission-control_backup_schedule" "sample-full" { Optional: - `cluster` (Block List, Max: 1) Cluster scope block (see [below for nested schema](#nestedblock--scope--cluster)) -- `cluster_group` (Block List, Max: 1) The schema for cluster group full name (see [below for nested schema](#nestedblock--scope--cluster_group)) +- `cluster_group` (Block List, Max: 1) Cluster group scope block (see [below for nested schema](#nestedblock--scope--cluster_group)) ### Nested Schema for `scope.cluster` @@ -703,40 +422,15 @@ Required: - `management_cluster_name` (String) Management cluster name - `provisioner_name` (String) Cluster provisioner name + ### Nested Schema for `scope.cluster_group` Required: -- `cluster_group_name` (String) Name of the cluster group - - -### Nested Schema for `selector` - -Optional: - -- `excludednames` (List of String) -- `labelselector` (Block List) (see [below for nested schema](#nestedblock--selector--labelselector)) -- `names` (List of String) - - -### Nested Schema for `selector.labelselector` - -Optional: +- `cluster_group_name` (String) Cluster group name -- `matchexpressions` (Block List) (see [below for nested schema](#nestedblock--selector--labelselector--matchexpressions)) - -### Nested Schema for `selector.labelselector.matchexpressions` - -Required: - -- `values` (List of String) - -Optional: - -- `key` (String) -- `operator` (String) ### Nested Schema for `spec` @@ -765,54 +459,54 @@ Optional: - `backup_ttl` (String) The backup retention period. - `csi_snapshot_timeout` (String) Specifies the time used to wait for CSI VolumeSnapshot status turns to ReadyToUse during creation, before returning error as timeout. - The default value is 10 minute. - Format is the time number and time sign, example: "50s" (50 seconds) +The default value is 10 minute. +Format is the time number and time sign, example: "50s" (50 seconds) - `default_volumes_to_fs_backup` (Boolean) Specifies whether all pod volumes should be backed up via file system backup by default. - (Default: True) +(Default: True) - `default_volumes_to_restic` (Boolean) Specifies whether restic should be used to take a backup of all pod volumes by default. - (Default: False) +(Default: False) +- `excluded_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to exclude from the backup. +If set to "*", all cluster-scoped resource types are excluded. +- `excluded_namespace_scoped_resources` (List of String) List of of namespace-scoped resource type names to exclude from the backup. +If set to "*", all namespace-scoped resource types are excluded. - `excluded_namespaces` (List of String) The namespaces to be excluded in the backup. - Can't be used if scope is SET_NAMESPACES. +Can't be used if scope is SET_NAMESPACES. - `excluded_resources` (List of String) The name list for the resources to be excluded in backup. - `hooks` (Block List, Max: 1) Hooks block represent custom actions that should be executed at different phases of the backup. (see [below for nested schema](#nestedblock--spec--template--hooks)) - `include_cluster_resources` (Boolean) A flag which specifies whether cluster-scoped resources should be included for consideration in the backup. - If set to true, all cluster-scoped resources will be backed up. If set to false, all cluster-scoped resources will be excluded from the backup. - If unset, all cluster-scoped resources are included if and only if all namespaces are included and there are no excluded namespaces. - Otherwise, only cluster-scoped resources associated with namespace-scoped resources included in the backup spec are backed up. - For example, if a PersistentVolumeClaim is included in the backup, its associated PersistentVolume (which is cluster-scoped) would also be backed up. - (Default: False) +If set to true, all cluster-scoped resources will be backed up. If set to false, all cluster-scoped resources will be excluded from the backup. +If unset, all cluster-scoped resources are included if and only if all namespaces are included and there are no excluded namespaces. +Otherwise, only cluster-scoped resources associated with namespace-scoped resources included in the backup spec are backed up. +For example, if a PersistentVolumeClaim is included in the backup, its associated PersistentVolume (which is cluster-scoped) would also be backed up. +(Default: False) +- `included_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to include in the backup. +If set to "*", all cluster-scoped resource types are included. + The default value is empty, which means only related cluster-scoped resources are included. +- `included_namespace_scoped_resources` (List of String) List of of namespace-scoped resource type names to include in the backup. +The default value is "*". - `included_namespaces` (List of String) The namespace to be included for backup from. - If empty, all namespaces are included. - Can't be used if scope is FULL_CLUSTER. - Required if scope is SET_NAMESPACES. +If empty, all namespaces are included. +Can't be used if scope is FULL_CLUSTER. +Required if scope is SET_NAMESPACES. - `included_resources` (List of String) The name list for the resources to be included into backup. If empty, all resources are included. - `label_selector` (Block List, Max: 1) The label selector to selectively adding individual objects to the backup schedule. - If not specified, all objects are included. - Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. - Required if scope is LABEL_SELECTOR and Or Label Selectors are not defined (see [below for nested schema](#nestedblock--spec--template--label_selector)) +If not specified, all objects are included. +Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. +Required if scope is LABEL_SELECTOR and Or Label Selectors are not defined (see [below for nested schema](#nestedblock--spec--template--label_selector)) - `or_label_selector` (Block List) (Repeatable Block) A list of label selectors to filter with when adding individual objects to the backup. - If multiple provided they will be joined by the OR operator. - LabelSelector as well as OrLabelSelectors cannot co-exist in backup request, only one of them can be used. - Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. - Required if scope is LABEL_SELECTOR and Label Selector is not defined (see [below for nested schema](#nestedblock--spec--template--or_label_selector)) +If multiple provided they will be joined by the OR operator. +LabelSelector as well as OrLabelSelectors cannot co-exist in backup request, only one of them can be used. +Can't be used if scope is FULL_CLUSTER or SET_NAMESPACES. +Required if scope is LABEL_SELECTOR and Label Selector is not defined (see [below for nested schema](#nestedblock--spec--template--or_label_selector)) - `ordered_resources` (Map of String) Specifies the backup order of resources of specific Kind. The map key is the Kind name and value is a list of resource names separated by commas. - Each resource name has format "namespace/resourcename". - For cluster resources, simply use "resourcename". +Each resource name has format "namespace/resourcename". +For cluster resources, simply use "resourcename". +- `snapshot_move_data` (Boolean) Specifies whether snapshot data should be moved to the target location.(Default:False) - `snapshot_volumes` (Boolean) A flag which specifies whether to take cloud snapshots of any PV's referenced in the set of objects included in the Backup. - If set to true, snapshots will be taken, otherwise, snapshots will be skipped. - If left unset, snapshots will be attempted if volume snapshots are configured for the cluster. +If set to true, snapshots will be taken, otherwise, snapshots will be skipped. +If left unset, snapshots will be attempted if volume snapshots are configured for the cluster. - `storage_location` (String) The name of a BackupStorageLocation where the backup should be stored. - `volume_snapshot_locations` (List of String) A list containing names of VolumeSnapshotLocations associated with this backup. -- `included_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to include in the backup. - If set to "*", all cluster-scoped resource types are included. - The default value is empty, which means only related cluster-scoped resources are included. -- `excluded_cluster_scoped_resources` (List of String) List of cluster-scoped resource type names to exclude from the backup. - If set to "*", all cluster-scoped resource types are excluded. -- `included_namespace_scoped_resources` (List of String) List of namespace-scoped resource type names to include in the backup. - The default value is "*". -- `excluded_namespace_scoped_resources` (List of String) List of namespace-scoped resource type names to exclude from the backup. - If set to "*", all namespace-scoped resource types are excluded. -- `snapshot_move_data` (Boolean) A flag which specifies whether snapshot data should be moved to the target location. Read-Only: @@ -836,13 +530,13 @@ Optional: - `excluded_namespaces` (List of String) Specifies the namespaces to which this hook spec does not apply. - `included_namespaces` (List of String) Specifies the namespaces to which this hook spec applies. - If empty, it applies to all namespaces. +If empty, it applies to all namespaces. - `label_selector` (Block List, Max: 1) The label selector to selectively adding individual objects to the hook resource. - If not specified, all objects are included. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--label_selector)) +If not specified, all objects are included. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--label_selector)) - `post_hook` (Block List) (Repeatable Block) A list of backup hooks to execute after storing the item in the backup. - These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--post_hook)) +These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--post_hook)) - `pre_hook` (Block List) (Repeatable Block) A list of backup hooks to execute after storing the item in the backup. - These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--pre_hook)) +These are executed after all "additional items" from item actions are processed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--pre_hook)) ### Nested Schema for `spec.template.hooks.resource.label_selector` @@ -851,7 +545,7 @@ Optional: - `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--hooks--resource--label_selector--match_expression)) - `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". - The requirements are ANDed. +The requirements are ANDed. ### Nested Schema for `spec.template.hooks.resource.label_selector.match_expression` @@ -860,14 +554,14 @@ Required: - `key` (String) Key is the label key that the selector applies to. - `operator` (String) Operator represents a key's relationship to a set of values. - Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". +Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". Optional: - `values` (List of String) Values is an array of string values. - If the operator is "In" or "NotIn", the values array must be non-empty. - If the operator is "Exists" or "DoesNotExist", the values array must be empty. - This array is replaced during a strategic merge patch. +If the operator is "In" or "NotIn", the values array must be non-empty. +If the operator is "Exists" or "DoesNotExist", the values array must be empty. +This array is replaced during a strategic merge patch. @@ -885,12 +579,12 @@ Required: - `command` (List of String) The command and arguments to execute. - `container` (String) The container in the pod where the command should be executed. - If not specified, the pod's first container is used. +If not specified, the pod's first container is used. Optional: - `on_error` (String) Specifies how Velero should behave if it encounters an error executing this hook. - Valid values are (FAIL, CONTINUE) +Valid values are (FAIL, CONTINUE) - `timeout` (String) Defines the maximum amount of time Velero should wait for the hook to complete before considering the execution a failure. @@ -909,12 +603,12 @@ Required: - `command` (List of String) The command and arguments to execute. - `container` (String) The container in the pod where the command should be executed. - If not specified, the pod's first container is used. +If not specified, the pod's first container is used. Optional: - `on_error` (String) Specifies how Velero should behave if it encounters an error executing this hook. - Valid values are (FAIL, CONTINUE) +Valid values are (FAIL, CONTINUE) - `timeout` (String) Defines the maximum amount of time Velero should wait for the hook to complete before considering the execution a failure. @@ -928,7 +622,7 @@ Optional: - `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--label_selector--match_expression)) - `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". - The requirements are ANDed. +The requirements are ANDed. ### Nested Schema for `spec.template.label_selector.match_expression` @@ -937,14 +631,14 @@ Required: - `key` (String) Key is the label key that the selector applies to. - `operator` (String) Operator represents a key's relationship to a set of values. - Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". +Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". Optional: - `values` (List of String) Values is an array of string values. - If the operator is "In" or "NotIn", the values array must be non-empty. - If the operator is "Exists" or "DoesNotExist", the values array must be empty. - This array is replaced during a strategic merge patch. +If the operator is "In" or "NotIn", the values array must be non-empty. +If the operator is "Exists" or "DoesNotExist", the values array must be empty. +This array is replaced during a strategic merge patch. @@ -955,7 +649,7 @@ Optional: - `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--spec--template--or_label_selector--match_expression)) - `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". - The requirements are ANDed. +The requirements are ANDed. ### Nested Schema for `spec.template.or_label_selector.match_expression` @@ -964,16 +658,19 @@ Required: - `key` (String) Key is the label key that the selector applies to. - `operator` (String) Operator represents a key's relationship to a set of values. - Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". +Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". Optional: - `values` (List of String) Values is an array of string values. - If the operator is "In" or "NotIn", the values array must be non-empty. - If the operator is "Exists" or "DoesNotExist", the values array must be empty. - This array is replaced during a strategic merge patch. +If the operator is "In" or "NotIn", the values array must be non-empty. +If the operator is "Exists" or "DoesNotExist", the values array must be empty. +This array is replaced during a strategic merge patch. + + + + - ### Nested Schema for `meta` @@ -987,3 +684,39 @@ Read-Only: - `resource_version` (String) Resource version of the resource - `uid` (String) UID of the resource + + + +### Nested Schema for `selector` + +Optional: + +- `excluded_names` (List of String) Specifies the name of excluded clusters. +- `label_selector` (Block List, Max: 1) The label selector to selectively adding individual clusters to the cluster group backup schedule. +If not specified, all clusters are included. (see [below for nested schema](#nestedblock--selector--label_selector)) +- `names` (List of String) Specifies name of cluster to be selected. + + +### Nested Schema for `selector.label_selector` + +Optional: + +- `match_expression` (Block List) (Repeatable Block) A list of label selector requirements. The requirements are ANDed. (see [below for nested schema](#nestedblock--selector--label_selector--match_expression)) +- `match_labels` (Map of String) A map of {key,value} pairs. A single {key,value} in the map is equivalent to an element of match_expressions, whose key field is "key", the operator is "In" and the values array contains only "value". +The requirements are ANDed. + + +### Nested Schema for `selector.label_selector.match_expression` + +Required: + +- `key` (String) Key is the label key that the selector applies to. +- `operator` (String) Operator represents a key's relationship to a set of values. +Valid operators are "In", "NotIn", "Exists" and "DoesNotExist". + +Optional: + +- `values` (List of String) Values is an array of string values. +If the operator is "In" or "NotIn", the values array must be non-empty. +If the operator is "Exists" or "DoesNotExist", the values array must be empty. +This array is replaced during a strategic merge patch. diff --git a/docs/resources/enable_data_protection.md b/docs/resources/enable_data_protection.md index c5125151c..d831d8759 100644 --- a/docs/resources/enable_data_protection.md +++ b/docs/resources/enable_data_protection.md @@ -1,7 +1,7 @@ --- Title: "Data Protection Resource" Description: |- - Enabling data protection on a cluster. + Enabling data protection --- # Cluster Data Protection Resource @@ -73,6 +73,14 @@ resource "tanzu-mission-control_enable_data_protection" "cgdemo" { } ``` + +**NOTE :** To resolve cluster and cluster group data protection conflicts use the below command +``terraform refresh`` + +For instance, in case cluster group data protection is created on already existing data protection at cluster level. +Use above command and remove cluster level data protection resource from the terraform file. +Similarly, in case of disable data protection, use above command and remove associated backup schedule from terraform file. + ## Import Cluster Scope Data Protection The resource ID for importing an existing data protection should be comprised of a full cluster name separated by '/'. diff --git a/internal/resources/backupschedule/resource_backup_schedule.go b/internal/resources/backupschedule/resource_backup_schedule.go index 218dc217f..5e8274044 100644 --- a/internal/resources/backupschedule/resource_backup_schedule.go +++ b/internal/resources/backupschedule/resource_backup_schedule.go @@ -139,19 +139,19 @@ func resourceBackupScheduleRead(ctx context.Context, data *schema.ResourceData, resp, err := readResourceWait(ctx, &config, backupScheduleFn) + // check if managed at cluster group level then remove from state + if resp != nil && resp.Schedule != nil && resp.Schedule.Meta != nil { + if _, ok := resp.Schedule.Meta.Annotations[commonscope.BatchUIDAnnotationKey]; ok { + _ = schema.RemoveFromState(data, m) + return diags + } + } + if err != nil { if clienterrors.IsNotFoundError(err) { - if !helper.IsContextCallerSet(ctx) { - *data = schema.ResourceData{} - - return diags - } else if helper.IsDeleteState(ctx) { - // d.SetId("") is automatically called assuming delete returns no errors, but - // it is added here for explicitness. - _ = schema.RemoveFromState(data, m) - - return diags - } + // resource not found in backend then delete the state + _ = schema.RemoveFromState(data, m) + return diags } return diag.FromErr(errors.Wrapf(err, "Couldn't read backup schedule.\nManagement Cluster Name: %s, Provisioner Name: %s, Cluster Name: %s, Schedule Name: %s", diff --git a/internal/resources/common/scope/constants.go b/internal/resources/common/scope/constants.go index eab59a7cd..84395f4e5 100644 --- a/internal/resources/common/scope/constants.go +++ b/internal/resources/common/scope/constants.go @@ -21,6 +21,7 @@ const ( ClusterKey = "cluster" ClusterGroupKey = "cluster_group" ClusterGroupNameKey = "cluster_group_name" + BatchUIDAnnotationKey = "tmc.cloud.vmware.com/source-uid" ) // Scopes. diff --git a/internal/resources/dataprotection/resource_enable_data_protection.go b/internal/resources/dataprotection/resource_enable_data_protection.go index 4cfec0be0..04201693c 100644 --- a/internal/resources/dataprotection/resource_enable_data_protection.go +++ b/internal/resources/dataprotection/resource_enable_data_protection.go @@ -20,6 +20,8 @@ import ( "github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper" dataprotectionmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/dataprotection" dataprotectioncgmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/clustergroup/dataprotection" + "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/common" + commonscope "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/common/scope" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/dataprotection/scope" ) @@ -64,6 +66,18 @@ func resourceEnableDataProtectionRead(ctx context.Context, data *schema.Resource config := m.(authctx.TanzuContext) err := populateDataFromServer(ctx, config, scopedFullnameData, data) + + if scopedFullnameData.Scope == scope.ClusterScope { + metaData := data.Get(common.MetaKey).([]interface{})[0].(map[string]interface{}) + annotations := metaData[common.AnnotationsKey].(map[string]interface{}) + + if _, ok := annotations[commonscope.BatchUIDAnnotationKey]; ok { + _ = schema.RemoveFromState(data, m) + + return diags + } + } + if err != nil { if clienterrors.IsNotFoundError(err) { if !helper.IsContextCallerSet(ctx) { diff --git a/templates/data-sources/backup_schedule.md.tmpl b/templates/data-sources/backup_schedule.md.tmpl index 67a0675a3..a2ffee3b8 100644 --- a/templates/data-sources/backup_schedule.md.tmpl +++ b/templates/data-sources/backup_schedule.md.tmpl @@ -1,16 +1,22 @@ --- Title: "Backup Schedule Data Source" Description: |- - Listing backup schedules by cluster scope + Listing backup schedules --- # Backup Schedule Data Source -This data source enables users to list existing backup schedules by cluster scope. -Listing target locations by cluster scope is supported only for clusters enabled with data protection. +This data source enables users to list existing backup schedules by cluster or cluster group scope. +Listing backup schedules by cluster or cluster group scope is supported only for clusters/cluster-groups enabled with data protection. -## Example Usage +## Cluster Backup Schedule +### Example Usage {{ tffile "examples/data-sources/backupschedule/data_source_backup_schedule.tf" }} +## Cluster Group Backup Schedule +### Example Usage + +{{ tffile "examples/data-sources/backupschedule/data_source_cluster_group_backup_schedule.tf" }} + {{ .SchemaMarkdown | trimspace }} diff --git a/templates/guides/tanzu-mission-control_data_protection.md.tmpl b/templates/guides/tanzu-mission-control_data_protection.md.tmpl index 7dd6a990e..88097c10a 100644 --- a/templates/guides/tanzu-mission-control_data_protection.md.tmpl +++ b/templates/guides/tanzu-mission-control_data_protection.md.tmpl @@ -1,13 +1,16 @@ --- Title: "Data Protection of a Tanzu Kubernetes Cluster" Description: |- - An example of using Data Protection Feature for a Tanzu Kubernetes Cluster + An example of using Data Protection Feature for a Tanzu Kubernetes Cluster/Cluster Group --- # Enable Data Protection The `tanzu-mission-control_enable_data_protection` resource enables users to activate and set up data protection for a Tanzu Kubernetes Cluster. Once enabled, users can create instant backups or schedule backups for later. +**NOTE :** To resolve cluster and cluster group data protection conflicts use the below command +``terraform refresh`` + For more information regarding data protection, see [Data Protection][data-protection]. [data-protection]: https://docs.vmware.com/en/VMware-Tanzu-Mission-Control/services/tanzumc-concepts/GUID-C16557BC-EB1B-4414-8E63-28AD92E0CAE5.html @@ -26,7 +29,10 @@ For more information regarding target location, see [Target Location][target-loc # Backup Schedule -The `tanzu-mission-control_backup_schedule` resource enables users to create and configure scheduled backups in a cluster. +The `tanzu-mission-control_backup_schedule` resource enables users to create and configure scheduled backups in a cluster/cluster-group. + +NOTE : To resolve cluster and cluster group backup schedule conflicts use the below command +``terraform refresh`` Backups can be applied in 3 levels: diff --git a/templates/resources/backup_schedule.md.tmpl b/templates/resources/backup_schedule.md.tmpl index 1e1a02706..bacfc8b73 100644 --- a/templates/resources/backup_schedule.md.tmpl +++ b/templates/resources/backup_schedule.md.tmpl @@ -1,12 +1,12 @@ --- Title: "Backup Schedule Resource" Description: |- - Creating a backup schedule for cluster. + Creating a backup schedule. --- # Backup Schedule Resource -This resource enables users to create and configure scheduled backups in a cluster. +This resource enables users to create and configure scheduled backups in a cluster or cluster group level. Backups can be applied in 3 levels: * Entire Cluster @@ -17,6 +17,12 @@ For more information regarding scheduled backups, see [Scheduled Backups][backup [backup-schedule]: https://docs.vmware.com/en/VMware-Tanzu-Mission-Control/services/tanzumc-using/GUID-89926F80-050A-4F1C-9D04-D56D5F453995.html?hWord=N4IghgNiBcIEZgMYGsCuAHABAZ0QCwFMATVCAkAXyA +**NOTE :** To resolve cluster and cluster group backup schedule conflicts use the below command +``terraform refresh`` + +For instance, in case cluster group/cluster data protection is disabled then use above command +and remove cluster group/cluster backup schedule resource from terraform file. + # Entire Cluster Weekly Backup Schedule ## Example Usage @@ -36,6 +42,26 @@ For more information regarding scheduled backups, see [Scheduled Backups][backup {{ tffile "examples/resources/backupschedule/resource_backup_schedule_labels.tf" }} + +# Entire Cluster Group Weekly Backup Schedule + +## Example Usage + +{{ tffile "examples/resources/backupschedule/resource_backup_schedule_cg_full_cluster.tf" }} + + +# Selected Namespaces Hourly Cluster Group Backup Schedule + +## Example Usage + +{{ tffile "examples/resources/backupschedule/resource_backup_schedule_cg_namespaces.tf" }} + +# Resources Selection By Label Selector Cluster Group Backup Schedule + +## Example Usage + +{{ tffile "examples/resources/backupschedule/resource_backup_schedule_cg_labels.tf" }} + ## Import Backup Schedule The resource ID for importing an existing backup schedule should be comprised of a full cluster name and a backup schedule name separated by '/'. diff --git a/templates/resources/enable_data_protection.md.tmpl b/templates/resources/enable_data_protection.md.tmpl index 9d3425972..e465a9d5d 100644 --- a/templates/resources/enable_data_protection.md.tmpl +++ b/templates/resources/enable_data_protection.md.tmpl @@ -1,7 +1,7 @@ --- Title: "Data Protection Resource" Description: |- - Enabling data protection on a cluster. + Enabling data protection --- # Cluster Data Protection Resource @@ -21,6 +21,14 @@ For more information regarding data protection, see [Data Protection][data-prote {{ tffile "examples/resources/dataprotection/resource_enable_data_protection_cluster_group.tf" }} + +**NOTE :** To resolve cluster and cluster group data protection conflicts use the below command +``terraform refresh`` + +For instance, in case cluster group data protection is created on already existing data protection at cluster level. +Use above command and remove cluster level data protection resource from the terraform file. +Similarly, in case of disable data protection, use above command and remove associated backup schedule from terraform file. + ## Import Cluster Scope Data Protection The resource ID for importing an existing data protection should be comprised of a full cluster name separated by '/'.