1// Copyright 2023 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.v1; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/gkebackup/v1/common.proto"; 22import "google/protobuf/timestamp.proto"; 23 24option csharp_namespace = "Google.Cloud.GkeBackup.V1"; 25option go_package = "cloud.google.com/go/gkebackup/apiv1/gkebackuppb;gkebackuppb"; 26option java_multiple_files = true; 27option java_outer_classname = "RestoreProto"; 28option java_package = "com.google.cloud.gkebackup.v1"; 29option php_namespace = "Google\\Cloud\\GkeBackup\\V1"; 30option ruby_package = "Google::Cloud::GkeBackup::V1"; 31 32// Represents both a request to Restore some portion of a Backup into 33// a target GKE cluster and a record of the restore operation itself. 34message Restore { 35 option (google.api.resource) = { 36 type: "gkebackup.googleapis.com/Restore" 37 pattern: "projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}" 38 }; 39 40 // Possible values for state of the Restore. 41 enum State { 42 // The Restore resource is in the process of being created. 43 STATE_UNSPECIFIED = 0; 44 45 // The Restore resource has been created and the associated RestoreJob 46 // Kubernetes resource has been injected into target cluster. 47 CREATING = 1; 48 49 // The gkebackup agent in the cluster has begun executing the restore 50 // operation. 51 IN_PROGRESS = 2; 52 53 // The restore operation has completed successfully. Restored workloads may 54 // not yet be operational. 55 SUCCEEDED = 3; 56 57 // The restore operation has failed. 58 FAILED = 4; 59 60 // This Restore resource is in the process of being deleted. 61 DELETING = 5; 62 } 63 64 // Output only. The full name of the Restore resource. 65 // Format: `projects/*/locations/*/restorePlans/*/restores/*` 66 string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 67 68 // Output only. Server generated global unique identifier of 69 // [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) format. 70 string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 71 72 // Output only. The timestamp when this Restore resource was created. 73 google.protobuf.Timestamp create_time = 3 74 [(google.api.field_behavior) = OUTPUT_ONLY]; 75 76 // Output only. The timestamp when this Restore resource was last 77 // updated. 78 google.protobuf.Timestamp update_time = 4 79 [(google.api.field_behavior) = OUTPUT_ONLY]; 80 81 // User specified descriptive string for this Restore. 82 string description = 5; 83 84 // Required. Immutable. A reference to the 85 // [Backup][google.cloud.gkebackup.v1.Backup] used as the source from which 86 // this Restore will restore. Note that this Backup must be a sub-resource of 87 // the RestorePlan's 88 // [backup_plan][google.cloud.gkebackup.v1.RestorePlan.backup_plan]. Format: 89 // `projects/*/locations/*/backupPlans/*/backups/*`. 90 string backup = 6 [ 91 (google.api.field_behavior) = IMMUTABLE, 92 (google.api.field_behavior) = REQUIRED, 93 (google.api.resource_reference) = { 94 type: "gkebackup.googleapis.com/Backup" 95 } 96 ]; 97 98 // Output only. The target cluster into which this Restore will restore data. 99 // Valid formats: 100 // 101 // - `projects/*/locations/*/clusters/*` 102 // - `projects/*/zones/*/clusters/*` 103 // 104 // Inherited from parent RestorePlan's 105 // [cluster][google.cloud.gkebackup.v1.RestorePlan.cluster] value. 106 string cluster = 7 [ 107 (google.api.field_behavior) = OUTPUT_ONLY, 108 (google.api.resource_reference) = { 109 type: "container.googleapis.com/Cluster" 110 } 111 ]; 112 113 // Output only. Configuration of the Restore. Inherited from parent 114 // RestorePlan's 115 // [restore_config][google.cloud.gkebackup.v1.RestorePlan.restore_config]. 116 RestoreConfig restore_config = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; 117 118 // A set of custom labels supplied by user. 119 map<string, string> labels = 9; 120 121 // Output only. The current state of the Restore. 122 State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; 123 124 // Output only. Human-readable description of why the Restore is in its 125 // current state. 126 string state_reason = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; 127 128 // Output only. Timestamp of when the restore operation completed. 129 google.protobuf.Timestamp complete_time = 12 130 [(google.api.field_behavior) = OUTPUT_ONLY]; 131 132 // Output only. Number of resources restored during the restore execution. 133 int32 resources_restored_count = 13 134 [(google.api.field_behavior) = OUTPUT_ONLY]; 135 136 // Output only. Number of resources excluded during the restore execution. 137 int32 resources_excluded_count = 14 138 [(google.api.field_behavior) = OUTPUT_ONLY]; 139 140 // Output only. Number of resources that failed to be restored during the 141 // restore execution. 142 int32 resources_failed_count = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; 143 144 // Output only. Number of volumes restored during the restore execution. 145 int32 volumes_restored_count = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; 146 147 // Output only. `etag` is used for optimistic concurrency control as a way to 148 // help prevent simultaneous updates of a restore from overwriting each other. 149 // It is strongly suggested that systems make use of the `etag` in the 150 // read-modify-write cycle to perform restore updates in order to avoid 151 // race conditions: An `etag` is returned in the response to `GetRestore`, 152 // and systems are expected to put that etag in the request to 153 // `UpdateRestore` or `DeleteRestore` to ensure that their change will be 154 // applied to the same version of the resource. 155 string etag = 17 [(google.api.field_behavior) = OUTPUT_ONLY]; 156} 157 158// Configuration of a restore. 159message RestoreConfig { 160 // Defines how volume data should be restored. 161 enum VolumeDataRestorePolicy { 162 // Unspecified (illegal). 163 VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED = 0; 164 165 // For each PVC to be restored, create a new underlying volume and PV 166 // from the corresponding VolumeBackup contained within the Backup. 167 RESTORE_VOLUME_DATA_FROM_BACKUP = 1; 168 169 // For each PVC to be restored, attempt to reuse the original PV contained 170 // in the Backup (with its original underlying volume). This option 171 // is likely only usable when restoring a workload to its original cluster. 172 REUSE_VOLUME_HANDLE_FROM_BACKUP = 2; 173 174 // For each PVC to be restored, create PVC without any particular 175 // action to restore data. In this case, the normal Kubernetes provisioning 176 // logic would kick in, and this would likely result in either dynamically 177 // provisioning blank PVs or binding to statically provisioned PVs. 178 NO_VOLUME_DATA_RESTORATION = 3; 179 } 180 181 // Defines the behavior for handling the situation where cluster-scoped 182 // resources being restored already exist in the target cluster. 183 enum ClusterResourceConflictPolicy { 184 // Unspecified. Only allowed if no cluster-scoped resources will be 185 // restored. 186 CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED = 0; 187 188 // Do not attempt to restore the conflicting resource. 189 USE_EXISTING_VERSION = 1; 190 191 // Delete the existing version before re-creating it from the Backup. 192 // This is a dangerous option which could cause unintentional 193 // data loss if used inappropriately. For example, deleting a CRD will 194 // cause Kubernetes to delete all CRs of that type. 195 USE_BACKUP_VERSION = 2; 196 } 197 198 // Defines the behavior for handling the situation where sets of namespaced 199 // resources being restored already exist in the target cluster. 200 enum NamespacedResourceRestoreMode { 201 // Unspecified (invalid). 202 NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED = 0; 203 204 // When conflicting top-level resources (either Namespaces or 205 // ProtectedApplications, depending upon the scope) are encountered, this 206 // will first trigger a delete of the conflicting resource AND ALL OF ITS 207 // REFERENCED RESOURCES (e.g., all resources in the Namespace or all 208 // resources referenced by the ProtectedApplication) before restoring the 209 // resources from the Backup. This mode should only be used when you are 210 // intending to revert some portion of a cluster to an earlier state. 211 DELETE_AND_RESTORE = 1; 212 213 // If conflicting top-level resources (either Namespaces or 214 // ProtectedApplications, depending upon the scope) are encountered at the 215 // beginning of a restore process, the Restore will fail. If a conflict 216 // occurs during the restore process itself (e.g., because an out of band 217 // process creates conflicting resources), a conflict will be reported. 218 FAIL_ON_CONFLICT = 2; 219 } 220 221 // This is a direct map to the Kubernetes GroupKind type 222 // [GroupKind](https://godoc.org/k8s.io/apimachinery/pkg/runtime/schema#GroupKind) 223 // and is used for identifying specific "types" of resources to restore. 224 message GroupKind { 225 // Optional. API group string of a Kubernetes resource, e.g. 226 // "apiextensions.k8s.io", "storage.k8s.io", etc. 227 // Note: use empty string for core API group 228 string resource_group = 1 [(google.api.field_behavior) = OPTIONAL]; 229 230 // Optional. Kind of a Kubernetes resource, must be in UpperCamelCase 231 // (PascalCase) and singular form. E.g. "CustomResourceDefinition", 232 // "StorageClass", etc. 233 string resource_kind = 2 [(google.api.field_behavior) = OPTIONAL]; 234 } 235 236 // Defines the scope of cluster-scoped resources to restore. 237 // 238 // Some group kinds are not reasonable choices for a restore, and will cause 239 // an error if selected here. Any scope selection that would restore 240 // "all valid" resources automatically excludes these group kinds. 241 // - gkebackup.gke.io/BackupJob 242 // - gkebackup.gke.io/RestoreJob 243 // - metrics.k8s.io/NodeMetrics 244 // - migration.k8s.io/StorageState 245 // - migration.k8s.io/StorageVersionMigration 246 // - Node 247 // - snapshot.storage.k8s.io/VolumeSnapshotContent 248 // - storage.k8s.io/CSINode 249 // 250 // Some group kinds are driven by restore configuration elsewhere, 251 // and will cause an error if selected here. 252 // - Namespace 253 // - PersistentVolume 254 message ClusterResourceRestoreScope { 255 // Optional. A list of cluster-scoped resource group kinds to restore from 256 // the backup. If specified, only the selected resources will be restored. 257 // Mutually exclusive to any other field in the message. 258 repeated GroupKind selected_group_kinds = 1 259 [(google.api.field_behavior) = OPTIONAL]; 260 261 // Optional. A list of cluster-scoped resource group kinds to NOT restore 262 // from the backup. If specified, all valid cluster-scoped resources will be 263 // restored except for those specified in the list. 264 // Mutually exclusive to any other field in the message. 265 repeated GroupKind excluded_group_kinds = 2 266 [(google.api.field_behavior) = OPTIONAL]; 267 268 // Optional. If True, all valid cluster-scoped resources will be restored. 269 // Mutually exclusive to any other field in the message. 270 bool all_group_kinds = 3 [(google.api.field_behavior) = OPTIONAL]; 271 272 // Optional. If True, no cluster-scoped resources will be restored. 273 // This has the same restore scope as if the message is not defined. 274 // Mutually exclusive to any other field in the message. 275 bool no_group_kinds = 4 [(google.api.field_behavior) = OPTIONAL]; 276 } 277 278 // A transformation rule to be applied against Kubernetes resources as they 279 // are selected for restoration from a Backup. A rule contains both filtering 280 // logic (which resources are subject to substitution) and substitution logic. 281 message SubstitutionRule { 282 // Optional. (Filtering parameter) Any resource subject to substitution must 283 // be contained within one of the listed Kubernetes Namespace in the Backup. 284 // If this field is not provided, no namespace filtering will be performed 285 // (all resources in all Namespaces, including all cluster-scoped resources, 286 // will be candidates for substitution). 287 // To mix cluster-scoped and namespaced resources in the same rule, use an 288 // empty string ("") as one of the target namespaces. 289 repeated string target_namespaces = 1 290 [(google.api.field_behavior) = OPTIONAL]; 291 292 // Optional. (Filtering parameter) Any resource subject to substitution must 293 // belong to one of the listed "types". If this field is not provided, no 294 // type filtering will be performed (all resources of all types matching 295 // previous filtering parameters will be candidates for substitution). 296 repeated GroupKind target_group_kinds = 2 297 [(google.api.field_behavior) = OPTIONAL]; 298 299 // Required. This is a [JSONPath] 300 // (https://kubernetes.io/docs/reference/kubectl/jsonpath/) 301 // expression that matches specific fields of candidate 302 // resources and it operates as both a filtering parameter (resources that 303 // are not matched with this expression will not be candidates for 304 // substitution) as well as a field identifier (identifies exactly which 305 // fields out of the candidate resources will be modified). 306 string target_json_path = 3 [(google.api.field_behavior) = REQUIRED]; 307 308 // Optional. (Filtering parameter) This is a [regular expression] 309 // (https://en.wikipedia.org/wiki/Regular_expression) 310 // that is compared against the fields matched by the target_json_path 311 // expression (and must also have passed the previous filters). 312 // Substitution will not be performed against fields whose 313 // value does not match this expression. If this field is NOT specified, 314 // then ALL fields matched by the target_json_path expression will undergo 315 // substitution. Note that an empty (e.g., "", rather than unspecified) 316 // value for this field will only match empty fields. 317 string original_value_pattern = 4 [(google.api.field_behavior) = OPTIONAL]; 318 319 // Optional. This is the new value to set for any fields that pass the 320 // filtering and selection criteria. To remove a value from a Kubernetes 321 // resource, either leave this field unspecified, or set it to the empty 322 // string (""). 323 string new_value = 5 [(google.api.field_behavior) = OPTIONAL]; 324 } 325 326 // TransformationRuleAction defines a TransformationRule action based on the 327 // JSON Patch RFC (https://www.rfc-editor.org/rfc/rfc6902) 328 message TransformationRuleAction { 329 // Possible values for operations of a transformation rule action. 330 enum Op { 331 // Unspecified operation 332 OP_UNSPECIFIED = 0; 333 334 // The "remove" operation removes the value at the target location. 335 REMOVE = 1; 336 337 // The "move" operation removes the value at a specified location and 338 // adds it to the target location. 339 MOVE = 2; 340 341 // The "copy" operation copies the value at a specified location to the 342 // target location. 343 COPY = 3; 344 345 // The "add" operation performs one of the following functions, 346 // depending upon what the target location references: 347 // 1. If the target location specifies an array index, a new value is 348 // inserted into the array at the specified index. 349 // 2. If the target location specifies an object member that does not 350 // already exist, a new member is added to the object. 351 // 3. If the target location specifies an object member that does exist, 352 // that member's value is replaced. 353 ADD = 4; 354 355 // The "test" operation tests that a value at the target location is 356 // equal to a specified value. 357 TEST = 5; 358 359 // The "replace" operation replaces the value at the target location 360 // with a new value. The operation object MUST contain a "value" member 361 // whose content specifies the replacement value. 362 REPLACE = 6; 363 } 364 365 // Required. op specifies the operation to perform. 366 Op op = 1 [(google.api.field_behavior) = REQUIRED]; 367 368 // Optional. A string containing a JSON Pointer value that references the 369 // location in the target document to move the value from. 370 string from_path = 2 [(google.api.field_behavior) = OPTIONAL]; 371 372 // Optional. A string containing a JSON-Pointer value that references a 373 // location within the target document where the operation is performed. 374 string path = 3 [(google.api.field_behavior) = OPTIONAL]; 375 376 // Optional. A string that specifies the desired value in string format to 377 // use for transformation. 378 string value = 4 [(google.api.field_behavior) = OPTIONAL]; 379 } 380 381 // ResourceFilter specifies matching criteria to limit the scope of a 382 // change to a specific set of kubernetes resources that are selected for 383 // restoration from a backup. 384 message ResourceFilter { 385 // Optional. (Filtering parameter) Any resource subject to transformation 386 // must be contained within one of the listed Kubernetes Namespace in the 387 // Backup. If this field is not provided, no namespace filtering will be 388 // performed (all resources in all Namespaces, including all cluster-scoped 389 // resources, will be candidates for transformation). 390 repeated string namespaces = 1 [(google.api.field_behavior) = OPTIONAL]; 391 392 // Optional. (Filtering parameter) Any resource subject to transformation 393 // must belong to one of the listed "types". If this field is not provided, 394 // no type filtering will be performed (all resources of all types matching 395 // previous filtering parameters will be candidates for transformation). 396 repeated GroupKind group_kinds = 2 [(google.api.field_behavior) = OPTIONAL]; 397 398 // Optional. This is a [JSONPath] 399 // (https://github.com/json-path/JsonPath/blob/master/README.md) 400 // expression that matches specific fields of candidate 401 // resources and it operates as a filtering parameter (resources that 402 // are not matched with this expression will not be candidates for 403 // transformation). 404 string json_path = 3 [(google.api.field_behavior) = OPTIONAL]; 405 } 406 407 // A transformation rule to be applied against Kubernetes resources as they 408 // are selected for restoration from a Backup. A rule contains both filtering 409 // logic (which resources are subject to transform) and transformation logic. 410 message TransformationRule { 411 // Required. A list of transformation rule actions to take against candidate 412 // resources. Actions are executed in order defined - this order matters, as 413 // they could potentially interfere with each other and the first operation 414 // could affect the outcome of the second operation. 415 repeated TransformationRuleAction field_actions = 1 416 [(google.api.field_behavior) = REQUIRED]; 417 418 // Optional. This field is used to specify a set of fields that should be 419 // used to determine which resources in backup should be acted upon by the 420 // supplied transformation rule actions, and this will ensure that only 421 // specific resources are affected by transformation rule actions. 422 ResourceFilter resource_filter = 2 [(google.api.field_behavior) = OPTIONAL]; 423 424 // Optional. The description is a user specified string description of the 425 // transformation rule. 426 string description = 3 [(google.api.field_behavior) = OPTIONAL]; 427 } 428 429 // Optional. Specifies the mechanism to be used to restore volume data. 430 // Default: VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED (will be treated as 431 // NO_VOLUME_DATA_RESTORATION). 432 VolumeDataRestorePolicy volume_data_restore_policy = 1 433 [(google.api.field_behavior) = OPTIONAL]; 434 435 // Optional. Defines the behavior for handling the situation where 436 // cluster-scoped resources being restored already exist in the target 437 // cluster. This MUST be set to a value other than 438 // CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED if 439 // [cluster_resource_restore_scope][google.cloud.gkebackup.v1.RestoreConfig.cluster_resource_restore_scope] 440 // is not empty. 441 ClusterResourceConflictPolicy cluster_resource_conflict_policy = 2 442 [(google.api.field_behavior) = OPTIONAL]; 443 444 // Optional. Defines the behavior for handling the situation where sets of 445 // namespaced resources being restored already exist in the target cluster. 446 // This MUST be set to a value other than 447 // NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED. 448 NamespacedResourceRestoreMode namespaced_resource_restore_mode = 3 449 [(google.api.field_behavior) = OPTIONAL]; 450 451 // Optional. Identifies the cluster-scoped resources to restore from the 452 // Backup. Not specifying it means NO cluster resource will be restored. 453 ClusterResourceRestoreScope cluster_resource_restore_scope = 4 454 [(google.api.field_behavior) = OPTIONAL]; 455 456 // Specifies the namespaced resources to restore from the Backup. 457 // Only one of the entries may be specified. If not specified, NO namespaced 458 // resources will be restored. 459 // 460 // Note: Resources will never be restored into *managed* namespaces such as 461 // `kube-system`, `kube-public`, or `kube-node-lease`. These namespaces 462 // are silently skipped when 463 // [all_namespaces][google.cloud.gkebackup.v1.RestoreConfig.all_namespaces] is 464 // selected. Listing them explicitly will result in an error. 465 oneof namespaced_resource_restore_scope { 466 // Restore all namespaced resources in the Backup if set to "True". 467 // Specifying this field to "False" is an error. 468 bool all_namespaces = 5; 469 470 // A list of selected Namespaces to restore from the Backup. The listed 471 // Namespaces and all resources contained in them will be restored. 472 Namespaces selected_namespaces = 6; 473 474 // A list of selected ProtectedApplications to restore. The listed 475 // ProtectedApplications and all the resources to which they refer will be 476 // restored. 477 NamespacedNames selected_applications = 7; 478 479 // Do not restore any namespaced resources if set to "True". 480 // Specifying this field to "False" is not allowed. 481 bool no_namespaces = 9; 482 483 // A list of selected namespaces excluded from restoration. All 484 // namespaces except those in this list will be restored. 485 Namespaces excluded_namespaces = 10; 486 } 487 488 // Optional. A list of transformation rules to be applied against Kubernetes 489 // resources as they are selected for restoration from a Backup. Rules are 490 // executed in order defined - this order matters, as changes made by a rule 491 // may impact the filtering logic of subsequent rules. An empty list means no 492 // substitution will occur. 493 repeated SubstitutionRule substitution_rules = 8 494 [(google.api.field_behavior) = OPTIONAL]; 495 496 // Optional. A list of transformation rules to be applied against Kubernetes 497 // resources as they are selected for restoration from a Backup. Rules are 498 // executed in order defined - this order matters, as changes made by a rule 499 // may impact the filtering logic of subsequent rules. An empty list means no 500 // transformation will occur. 501 repeated TransformationRule transformation_rules = 11 502 [(google.api.field_behavior) = OPTIONAL]; 503} 504