1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.gkebackup.logging.v1; 18 19import "google/cloud/gkebackup/logging/v1/logged_common.proto"; 20 21option go_package = "cloud.google.com/go/gkebackup/logging/apiv1/loggingpb;loggingpb"; 22option java_multiple_files = true; 23option java_outer_classname = "LoggedRestorePlanProto"; 24option java_package = "google.cloud.gkebackup.logging.v1"; 25option csharp_namespace = "Google.Cloud.GkeBackup.Logging.V1"; 26option php_namespace = "Google\\Cloud\\GkeBackup\\Logging\\V1"; 27option ruby_package = "Google::Cloud::GkeBackup::Logging::V1"; 28 29// RestorePlan as stored in Platform log. It's used to log the details of 30// a createRestorePlan/updateRestorePlan request, so only fields that can be 31// taken from user input are included here. 32message LoggedRestorePlan { 33 // User specified descriptive string for this RestorePlan. 34 string description = 1; 35 36 // The BackupPlan from which Backups may be used as the source 37 // for Restores created via this RestorePlan. 38 // Format: projects/*/locations/*/backupPlans/*. 39 string backup_plan = 2; 40 41 // The target cluster into which Restores created via this RestorePlan 42 // will restore data. NOTE: the cluster's region must be the same as the 43 // RestorePlan. 44 // Possible formats: 45 // 1. projects/*/locations/*/clusters/* 46 // 2. projects/*/zones/*/clusters/* 47 string cluster = 3; 48 49 // Configuration of Restores created via this RestorePlan. 50 RestoreConfig restore_config = 4; 51 52 // A set of custom labels supplied by user. 53 map<string, string> labels = 5; 54} 55 56// Configuration of a restore. 57message RestoreConfig { 58 // This is a direct map to the Kubernetes GroupKind type 59 // [GroupKind](https://godoc.org/k8s.io/apimachinery/pkg/runtime/schema#GroupKind) 60 // and is used for identifying specific "types" of resources to restore. 61 message GroupKind { 62 // API group string of a Kubernetes resource, e.g. 63 // "apiextensions.k8s.io", "storage.k8s.io", etc. 64 // Note: use empty string for core API group 65 string resource_group = 1; 66 67 // Kind of a Kubernetes resource, e.g. 68 // "CustomResourceDefinition", "StorageClass", etc. 69 string resource_kind = 2; 70 } 71 72 // Identifies the cluster-scoped resources to restore from the Backup. 73 message ClusterResourceRestoreScope { 74 // A list of "types" of cluster-scoped resources to be restored from the 75 // Backup. An empty list means that NO cluster-scoped resources will be 76 // restored. Note that Namespaces and PersistentVolume restoration is 77 // handled separately and is not governed by this field. 78 repeated GroupKind selected_group_kinds = 1; 79 } 80 81 // A transformation rule to be applied against Kubernetes resources as they 82 // are selected for restoration from a Backup. A rule contains both filtering 83 // logic (which resources are subject to substitution) and substitution logic. 84 message SubstitutionRule { 85 // (Filtering parameter) Any resource subject to substitution must be 86 // contained within one of the listed Kubernetes Namespace in the Backup. 87 // If this field is not provided, no namespace filtering will be performed 88 // (all resources in all Namespaces, including all cluster-scoped resources, 89 // will be candidates for substitution). 90 // To mix cluster-scoped and namespaced resources in the same rule, use an 91 // empty string ("") as one of the target namespaces. 92 repeated string target_namespaces = 1; 93 94 // (Filtering parameter) Any resource subject to substitution must belong to 95 // one of the listed "types". 96 // If this field is not provided, no type filtering will be performed (all 97 // resources of all types matching previous filtering parameters will be 98 // candidates for substitution). 99 repeated GroupKind target_group_kinds = 2; 100 101 // This is a [JSONPath] 102 // ([https://kubernetes.io/docs/reference/kubectl/jsonpath/) 103 // expression that matches specific fields of candidate 104 // resources and it operates as both a filtering parameter (resources that 105 // are not matched with this expression will not be candidates for 106 // substitution) as well as a field identifier (identifies exactly which 107 // fields out of the candidate resources will be modified). 108 string target_json_path = 3; 109 110 // (Filtering parameter) This is a [regular expression] 111 // (https://en.wikipedia.org/wiki/Regular_expression) 112 // that is compared against the fields matched by the target_json_path 113 // expression (and must also have passed the previous filters). 114 // Substitution will not be performed against fields whose 115 // value does not match this expression. If this field is NOT specified, 116 // then ALL fields matched by the target_json_path expression will undergo 117 // substitution. Note that an empty (e.g., "", rather than unspecified) 118 // value for for this field will only match empty fields. 119 string original_value_pattern = 4; 120 121 // This is the new value to set for any fields that pass the filtering and 122 // selection criteria. To remove a value from a Kubernetes resource, either 123 // leave this field unspecified, or set it to the empty string (""). 124 string new_value = 5; 125 } 126 127 // Defines how volume data should be restored 128 enum VolumeDataRestorePolicy { 129 // unspecified, default value 130 VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED = 0; 131 132 // For each PVC to be restored, will create a new underlying volume (and PV) 133 // from the corresponding VolumeBackup contained within the Backup. 134 RESTORE_VOLUME_DATA_FROM_BACKUP = 1; 135 136 // For each PVC to be restored, attempt to reuse the original PV contained 137 // in the Backup (with its original underlying volume). Note that option 138 // is likely only usable when restoring a workload to its original cluster. 139 REUSE_VOLUME_HANDLE_FROM_BACKUP = 2; 140 141 // For each PVC to be restored, PVCs will be created without any particular 142 // action to restore data. In this case, the normal Kubernetes provisioning 143 // logic would kick in, and this would likely result in either dynamically 144 // provisioning blank PVs or binding to statically provisioned PVs. 145 NO_VOLUME_DATA_RESTORATION = 3; 146 } 147 148 // Defines the behavior for handling the situation where cluster-scoped 149 // resources being restored already exist in the target cluster. 150 enum ClusterResourceConflictPolicy { 151 // Unspecified. Only allowed if no cluster-scoped resources will be 152 // restored. 153 CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED = 0; 154 155 // Do not attempt to restore the conflicting resource. 156 USE_EXISTING_VERSION = 1; 157 158 // Delete the existing version before re-creating it from the Backup. 159 // Note that this is a dangerous option which could cause unintentional 160 // data loss if used inappropriately - for example, deleting a CRD will 161 // cause Kubernetes to delete all CRs of that type. 162 USE_BACKUP_VERSION = 2; 163 } 164 165 // Defines the behavior for handling the situation where sets of namespaced 166 // resources being restored already exist in the target cluster. 167 enum NamespacedResourceRestoreMode { 168 // Unspecified. Only allowed if no namespaced resources will be restored. 169 NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED = 0; 170 171 // When conflicting top-level resources (either Namespaces or 172 // ProtectedApplications, depending upon the scope) are encountered, this 173 // will first trigger a delete of the conflicting resource AND ALL OF ITS 174 // REFERENCED RESOURCES (e.g., all resources in the Namespace or all 175 // resources referenced by the ProtectedApplication) before restoring the 176 // resources from the Backup. This mode should only be used when you are 177 // intending to revert some portion of a cluster to an earlier state. 178 DELETE_AND_RESTORE = 1; 179 180 // If conflicting top-level resources (either Namespaces or 181 // ProtectedApplications, depending upon the scope) are encountered at the 182 // beginning of a restore process, the Restore will fail. If a conflict 183 // occurs during the restore process itself (e.g., because an out of band 184 // process creates conflicting resources), a conflict will be reported. 185 FAIL_ON_CONFLICT = 2; 186 } 187 188 // Specifies the mechanism to be used to restore volume data. 189 // Default: VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED (will be treated as 190 // NO_VOLUME_DATA_RESTORATION). 191 VolumeDataRestorePolicy volume_data_restore_policy = 1; 192 193 // Defines the behavior for handling the situation where cluster-scoped 194 // resources being restored already exist in the target cluster. This MUST be 195 // set to a value other than CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED if 196 // cluster_resource_restore_scope is not empty. 197 ClusterResourceConflictPolicy cluster_resource_conflict_policy = 2; 198 199 // Defines the behavior for handling the situation where sets of namespaced 200 // resources being restored already exist in the target cluster. This MUST be 201 // set to a value other than NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED if 202 // any namespaced restoration is configured via 203 // namespaced_resource_restore_scope . 204 NamespacedResourceRestoreMode namespaced_resource_restore_mode = 3; 205 206 // Identifies the cluster-scoped resources to restore from the Backup. 207 // Not specifying it means NO cluster resource will be restored. 208 ClusterResourceRestoreScope cluster_resource_restore_scope = 4; 209 210 // Specifies the namespaced resources to restore from the Backup. 211 // Only one of the entries may be specified. If not specified, NO namespaced 212 // resources will be restored. 213 oneof namespaced_resource_restore_scope { 214 // Restore all namespaced resources in the Backup if set to "True". 215 // Specifying this field to "False" is an error. 216 bool all_namespaces = 5; 217 218 // A list of selected Namespaces to restore from the Backup. The listed 219 // Namespaces and all resources contained in them will be restored. 220 Namespaces selected_namespaces = 6; 221 222 // A list of selected ProtectedApplications to restore. The listed 223 // ProtectedApplications and all the resources to which they refer will be 224 // restored. 225 NamespacedNames selected_applications = 7; 226 } 227 228 // A list of transformation rules to be applied against Kubernetes resources 229 // as they are selected for restoration from a Backup. Rules are executed in 230 // order defined - this order matters, as changes made by a rule may impact 231 // the filtering logic of subsequent rules. An empty list means no 232 // substitution will occur. 233 repeated SubstitutionRule substitution_rules = 8; 234} 235