logged_restore_plan.proto 11 KB

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