[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[],[],null,["# Modify resources during restoration (deprecated)\n\nAutopilot Standard\n\n*** ** * ** ***\n\n| **Deprecated:** You're viewing an obsolete version of resource modification.\n\nThis page describes how to make modifications to Kubernetes resources during the\nrestoration process.\n\nOverview\n--------\n\nThere are several reasons why you might want to modify Kubernetes resources as\npart of the restore process. For example:\n\n- You may want to provision PVCs using a different storage provisioner (for\n example, move from the Kubernetes in-tree driver to the CSI driver).\n\n- You may want to restore a namespace under a different name.\n\n- You may want to change a replica count in a Deployment or StatefulSet.\n\nBackup for GKE provides a mechanism for doing this called *substitution rules* which\nyou may optionally define as part of a [`RestorePlan`](/kubernetes-engine/docs/add-on/backup-for-gke/how-to/restore-plan#create_a_restore_plan).\n\nA substitution rule is a set of matching criteria specified together with a\nreplacement field value. You can use substitution rules in the restore process as follows:\n\n1. First, Backup for GKE computes the set of resources to restore, based on the scope\n parameters in the restore configuration (for example: namespaces, group/kinds, etc.)\n\n2. Backup for GKE evaluates each resource selected for restore against the\n ordered list of substitution rules. If a rule matches the resource, the\n resource is updated with the substituted field value. All resources are\n matched against all rules, and the same resource may potentially have\n multiple substitutions performed against it.\n\n3. After all the rules have been evaluated, Backup for GKE creates the\n resulting set of resources in the target cluster.\n\nSubstitution rule parameters\n----------------------------\n\nTo define a substitution rule, you provide the following parameters:\n\nTo learn more about defining substitution rules in the Google Cloud console, see [Plan a set of restores](/kubernetes-engine/docs/add-on/backup-for-gke/how-to/restore-plan#create_a_restore_plan).\n\nTo define substitution rules using the gcloud CLI, create a file\ncontaining a YAML array of substitutionRules and include the\n`--substitution-rules-file=` parameter to the\n[`gcloud beta container backup-restore restore-plans create`](/sdk/gcloud/reference/beta/container/backup-restore/restore-plans/create)\ncommand.\n\nSubstitution rule examples\n--------------------------\n\nThe following examples are provided in the YAML format used by\nthe gcloud CLI.\n\n### Change StorageClass\n\nIn this example, we change the StorageClass in all restored PersistentVolumeClaim resources from\n`standard` to `premium-rwo`: \n\n substitutionRules:\n - targetGroupKinds:\n - resourceGroup: ''\n resourceKind: PersistentVolumeClaim\n targetJsonPath: \"{..storageClassName}\"\n originalValuePattern: standard\n newValue: premium-rwo\n\n### Clone Namespace\n\nIn this example, we clone a namespace from alpha to beta---creating a new\nnamespace \"beta\" and restoring all of the resources from \"alpha\" into the new\n\"beta\" namespace. Note that this examples requires two substitution rules---one\nfor the namespace itself, and one for the resources within the namespace. \n\n substitutionRules:\n - targetNamespaces:\n - ''\n targetGroupKinds:\n - resourceGroup: ''\n resourceKind: Namespace\n targetJsonPath: \"{.metadata.name}\"\n originalValuePattern: alpha\n newValue: beta\n - targetNamespaces:\n - alpha\n targetJsonPath: \"{.metadata.namespace}\"\n originalValuePattern: alpha\n newValue: beta\n\n### Change StorageClass and replica count in a cloned namespace\n\nIn this example, we clone a namespace, and then apply a set of changes to the\nresources in the new namespace:\n\n- Change the StorageClass on PVCs from `standard` to `premium-rwo`\n\n- Change the replica count on Deployments from `7` to `3`\n\n substitutionRules:\n - targetNamespaces:\n - ''\n targetGroupKinds:\n - resourceGroup: ''\n resourceKind: Namespace\n targetJsonPath: \"{.metadata.name}\"\n originalValuePattern: alpha\n newValue: beta\n - targetNamespaces:\n - alpha\n targetJsonPath: \"{.metadata.namespace}\"\n originalValuePattern: alpha\n newValue: beta\n - targetNamespaces:\n - beta\n targetGroupKinds:\n - resourceGroup: ''\n resourceKind: PersistentVolumeClaim\n targetJsonPath: \"{..storageClassName}\"\n originalValuePattern: standard\n newValue: premium-rwo\n - targetNamespaces:\n - beta\n targetGroupKinds:\n - resourceGroup: apps\n resourceKind: Deployment\n targetJsonPath: \"{$.spec.replicas}\"\n originalValuePattern: '7'\n newValue: '3'"]]