restore.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.cloud.gkebackup.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/cloud/gkebackup/v1/common.proto";
  19. import "google/protobuf/timestamp.proto";
  20. option csharp_namespace = "Google.Cloud.GkeBackup.V1";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/gkebackup/v1;gkebackup";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "RestoreProto";
  24. option java_package = "com.google.cloud.gkebackup.v1";
  25. option php_namespace = "Google\\Cloud\\GkeBackup\\V1";
  26. option ruby_package = "Google::Cloud::GkeBackup::V1";
  27. // Represents both a request to Restore some portion of a Backup into
  28. // a target GKE cluster and a record of the restore operation itself.
  29. // Next id: 18
  30. message Restore {
  31. option (google.api.resource) = {
  32. type: "gkebackup.googleapis.com/Restore"
  33. pattern: "projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}"
  34. };
  35. // Possible values for state of the Restore.
  36. enum State {
  37. // The Restore resource is in the process of being created.
  38. STATE_UNSPECIFIED = 0;
  39. // The Restore resource has been created and the associated RestoreJob
  40. // Kubernetes resource has been injected into target cluster.
  41. CREATING = 1;
  42. // The gkebackup agent in the cluster has begun executing the restore
  43. // operation.
  44. IN_PROGRESS = 2;
  45. // The restore operation has completed successfully. Restored workloads may
  46. // not yet be operational.
  47. SUCCEEDED = 3;
  48. // The restore operation has failed.
  49. FAILED = 4;
  50. // This Restore resource is in the process of being deleted.
  51. DELETING = 5;
  52. }
  53. // Output only. The full name of the Restore resource.
  54. // Format: projects/*/locations/*/restorePlans/*/restores/*
  55. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  56. // Output only. Server generated global unique identifier of
  57. // [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) format.
  58. string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  59. // Output only. The timestamp when this Restore resource was created.
  60. google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  61. // Output only. The timestamp when this Restore resource was last
  62. // updated.
  63. google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  64. // User specified descriptive string for this Restore.
  65. string description = 5;
  66. // Required. Immutable. A reference to the [Backup][google.cloud.gkebackup.v1.Backup] used as the source from which this Restore
  67. // will restore. Note that this Backup must be a sub-resource of the
  68. // RestorePlan's [backup_plan][google.cloud.gkebackup.v1.RestorePlan.backup_plan].
  69. // Format: projects/*/locations/*/backupPlans/*/backups/*.
  70. string backup = 6 [
  71. (google.api.field_behavior) = IMMUTABLE,
  72. (google.api.field_behavior) = REQUIRED,
  73. (google.api.resource_reference) = {
  74. type: "gkebackup.googleapis.com/Backup"
  75. }
  76. ];
  77. // Output only. The target cluster into which this Restore will restore data.
  78. // Valid formats:
  79. //
  80. // - projects/*/locations/*/clusters/*
  81. // - projects/*/zones/*/clusters/*
  82. //
  83. // Inherited from parent RestorePlan's [cluster][google.cloud.gkebackup.v1.RestorePlan.cluster] value.
  84. string cluster = 7 [
  85. (google.api.field_behavior) = OUTPUT_ONLY,
  86. (google.api.resource_reference) = {
  87. type: "container.googleapis.com/Cluster"
  88. }
  89. ];
  90. // Output only. Configuration of the Restore. Inherited from parent RestorePlan's
  91. // [restore_config][google.cloud.gkebackup.v1.RestorePlan.restore_config].
  92. RestoreConfig restore_config = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
  93. // A set of custom labels supplied by user.
  94. map<string, string> labels = 9;
  95. // Output only. The current state of the Restore.
  96. State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  97. // Output only. Human-readable description of why the Restore is in its current state.
  98. string state_reason = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
  99. // Output only. Timestamp of when the restore operation completed.
  100. google.protobuf.Timestamp complete_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  101. // Output only. Number of resources restored during the restore execution.
  102. int32 resources_restored_count = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
  103. // Output only. Number of resources excluded during the restore execution.
  104. int32 resources_excluded_count = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
  105. // Output only. Number of resources that failed to be restored during the restore
  106. // execution.
  107. int32 resources_failed_count = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
  108. // Output only. Number of volumes restored during the restore execution.
  109. int32 volumes_restored_count = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
  110. // Output only. `etag` is used for optimistic concurrency control as a way to help
  111. // prevent simultaneous updates of a restore from overwriting each other.
  112. // It is strongly suggested that systems make use of the `etag` in the
  113. // read-modify-write cycle to perform restore updates in order to avoid
  114. // race conditions: An `etag` is returned in the response to `GetRestore`,
  115. // and systems are expected to put that etag in the request to
  116. // `UpdateRestore` or `DeleteRestore` to ensure that their change will be
  117. // applied to the same version of the resource.
  118. string etag = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
  119. }
  120. // Configuration of a restore.
  121. // Next id: 9
  122. message RestoreConfig {
  123. // Defines how volume data should be restored
  124. enum VolumeDataRestorePolicy {
  125. // Unspecified (illegal).
  126. VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED = 0;
  127. // For each PVC to be restored, will create a new underlying volume (and PV)
  128. // from the corresponding VolumeBackup contained within the Backup.
  129. RESTORE_VOLUME_DATA_FROM_BACKUP = 1;
  130. // For each PVC to be restored, attempt to reuse the original PV contained
  131. // in the Backup (with its original underlying volume). Note that option
  132. // is likely only usable when restoring a workload to its original cluster.
  133. REUSE_VOLUME_HANDLE_FROM_BACKUP = 2;
  134. // For each PVC to be restored, PVCs will be created without any particular
  135. // action to restore data. In this case, the normal Kubernetes provisioning
  136. // logic would kick in, and this would likely result in either dynamically
  137. // provisioning blank PVs or binding to statically provisioned PVs.
  138. NO_VOLUME_DATA_RESTORATION = 3;
  139. }
  140. // Defines the behavior for handling the situation where cluster-scoped
  141. // resources being restored already exist in the target cluster.
  142. enum ClusterResourceConflictPolicy {
  143. // Unspecified. Only allowed if no cluster-scoped resources will be
  144. // restored.
  145. CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED = 0;
  146. // Do not attempt to restore the conflicting resource.
  147. USE_EXISTING_VERSION = 1;
  148. // Delete the existing version before re-creating it from the Backup.
  149. // Note that this is a dangerous option which could cause unintentional
  150. // data loss if used inappropriately - for example, deleting a CRD will
  151. // cause Kubernetes to delete all CRs of that type.
  152. USE_BACKUP_VERSION = 2;
  153. }
  154. // Defines the behavior for handling the situation where sets of namespaced
  155. // resources being restored already exist in the target cluster.
  156. enum NamespacedResourceRestoreMode {
  157. // Unspecified (invalid).
  158. NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED = 0;
  159. // When conflicting top-level resources (either Namespaces or
  160. // ProtectedApplications, depending upon the scope) are encountered, this
  161. // will first trigger a delete of the conflicting resource AND ALL OF ITS
  162. // REFERENCED RESOURCES (e.g., all resources in the Namespace or all
  163. // resources referenced by the ProtectedApplication) before restoring the
  164. // resources from the Backup. This mode should only be used when you are
  165. // intending to revert some portion of a cluster to an earlier state.
  166. DELETE_AND_RESTORE = 1;
  167. // If conflicting top-level resources (either Namespaces or
  168. // ProtectedApplications, depending upon the scope) are encountered at the
  169. // beginning of a restore process, the Restore will fail. If a conflict
  170. // occurs during the restore process itself (e.g., because an out of band
  171. // process creates conflicting resources), a conflict will be reported.
  172. FAIL_ON_CONFLICT = 2;
  173. }
  174. // This is a direct map to the Kubernetes GroupKind type
  175. // [GroupKind](https://godoc.org/k8s.io/apimachinery/pkg/runtime/schema#GroupKind)
  176. // and is used for identifying specific "types" of resources to restore.
  177. message GroupKind {
  178. // API group string of a Kubernetes resource, e.g.
  179. // "apiextensions.k8s.io", "storage.k8s.io", etc.
  180. // Note: use empty string for core API group
  181. string resource_group = 1;
  182. // Kind of a Kubernetes resource, e.g.
  183. // "CustomResourceDefinition", "StorageClass", etc.
  184. string resource_kind = 2;
  185. }
  186. // Identifies the cluster-scoped resources to restore from the Backup.
  187. message ClusterResourceRestoreScope {
  188. // A list of "types" of cluster-scoped resources to be restored from the
  189. // Backup. An empty list means that NO cluster-scoped resources will be
  190. // restored. Note that Namespaces and PersistentVolume restoration is
  191. // handled separately and is not governed by this field.
  192. repeated GroupKind selected_group_kinds = 1;
  193. }
  194. // A transformation rule to be applied against Kubernetes resources as they
  195. // are selected for restoration from a Backup. A rule contains both filtering
  196. // logic (which resources are subject to substitution) and substitution logic.
  197. message SubstitutionRule {
  198. // (Filtering parameter) Any resource subject to substitution must be
  199. // contained within one of the listed Kubernetes Namespace in the Backup.
  200. // If this field is not provided, no namespace filtering will be performed
  201. // (all resources in all Namespaces, including all cluster-scoped resources,
  202. // will be candidates for substitution).
  203. // To mix cluster-scoped and namespaced resources in the same rule, use an
  204. // empty string ("") as one of the target namespaces.
  205. repeated string target_namespaces = 1;
  206. // (Filtering parameter) Any resource subject to substitution must belong to
  207. // one of the listed "types".
  208. // If this field is not provided, no type filtering will be performed (all
  209. // resources of all types matching previous filtering parameters will be
  210. // candidates for substitution).
  211. repeated GroupKind target_group_kinds = 2;
  212. // Required. This is a [JSONPath]
  213. // (https://kubernetes.io/docs/reference/kubectl/jsonpath/)
  214. // expression that matches specific fields of candidate
  215. // resources and it operates as both a filtering parameter (resources that
  216. // are not matched with this expression will not be candidates for
  217. // substitution) as well as a field identifier (identifies exactly which
  218. // fields out of the candidate resources will be modified).
  219. string target_json_path = 3 [(google.api.field_behavior) = REQUIRED];
  220. // (Filtering parameter) This is a [regular expression]
  221. // (https://en.wikipedia.org/wiki/Regular_expression)
  222. // that is compared against the fields matched by the target_json_path
  223. // expression (and must also have passed the previous filters).
  224. // Substitution will not be performed against fields whose
  225. // value does not match this expression. If this field is NOT specified,
  226. // then ALL fields matched by the target_json_path expression will undergo
  227. // substitution. Note that an empty (e.g., "", rather than unspecified)
  228. // value for for this field will only match empty fields.
  229. string original_value_pattern = 4;
  230. // This is the new value to set for any fields that pass the filtering and
  231. // selection criteria. To remove a value from a Kubernetes resource, either
  232. // leave this field unspecified, or set it to the empty string ("").
  233. string new_value = 5;
  234. }
  235. // Specifies the mechanism to be used to restore volume data.
  236. // Default: VOLUME_DATA_RESTORE_POLICY_UNSPECIFIED (will be treated as
  237. // NO_VOLUME_DATA_RESTORATION).
  238. VolumeDataRestorePolicy volume_data_restore_policy = 1;
  239. // Defines the behavior for handling the situation where cluster-scoped
  240. // resources being restored already exist in the target cluster. This MUST be
  241. // set to a value other than CLUSTER_RESOURCE_CONFLICT_POLICY_UNSPECIFIED if
  242. // [cluster_resource_restore_scope][google.cloud.gkebackup.v1.RestoreConfig.cluster_resource_restore_scope] is not empty.
  243. ClusterResourceConflictPolicy cluster_resource_conflict_policy = 2;
  244. // Defines the behavior for handling the situation where sets of namespaced
  245. // resources being restored already exist in the target cluster. This MUST be
  246. // set to a value other than NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED.
  247. NamespacedResourceRestoreMode namespaced_resource_restore_mode = 3;
  248. // Identifies the cluster-scoped resources to restore from the Backup.
  249. // Not specifying it means NO cluster resource will be restored.
  250. ClusterResourceRestoreScope cluster_resource_restore_scope = 4;
  251. // Specifies the namespaced resources to restore from the Backup.
  252. // Only one of the entries may be specified. If not specified, NO namespaced
  253. // resources will be restored.
  254. oneof namespaced_resource_restore_scope {
  255. // Restore all namespaced resources in the Backup if set to "True".
  256. // Specifying this field to "False" is an error.
  257. bool all_namespaces = 5;
  258. // A list of selected Namespaces to restore from the Backup. The listed
  259. // Namespaces and all resources contained in them will be restored.
  260. Namespaces selected_namespaces = 6;
  261. // A list of selected ProtectedApplications to restore. The listed
  262. // ProtectedApplications and all the resources to which they refer will be
  263. // restored.
  264. NamespacedNames selected_applications = 7;
  265. }
  266. // A list of transformation rules to be applied against Kubernetes resources
  267. // as they are selected for restoration from a Backup. Rules are executed in
  268. // order defined - this order matters, as changes made by a rule may impact
  269. // the filtering logic of subsequent rules. An empty list means no
  270. // substitution will occur.
  271. repeated SubstitutionRule substitution_rules = 8;
  272. }