[[["易于理解","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-02。"],[[["\u003cp\u003eConfig Connector manages resources at the project, folder, or organization level, determining the resource's creation location through a scope-defining field or annotation.\u003c/p\u003e\n"],["\u003cp\u003eMost folder-scoped resources use the \u003ccode\u003efolderRef\u003c/code\u003e field in their CRD spec to specify the Google Cloud folder, either by referencing a Kubernetes-managed Folder resource or directly specifying the folder ID via the \u003ccode\u003eexternal\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003eFor folder-scoped resources without the \u003ccode\u003efolderRef\u003c/code\u003e field, you can use the \u003ccode\u003ecnrm.cloud.google.com/folder-id\u003c/code\u003e annotation within the resource's metadata to designate the folder ID.\u003c/p\u003e\n"],["\u003cp\u003eYou can apply a default folder ID to all newly created resources within a Kubernetes namespace by using the annotation \u003ccode\u003ecnrm.cloud.google.com/folder-id=FOLDER_ID\u003c/code\u003e at the namespace level, which can be overwritten by a resource-level annotation if needed.\u003c/p\u003e\n"]]],[],null,["# Folder-scoped resources\n=======================\n\n*** ** * ** ***\n\nConfig Connector can manage your resources at the project, folder, or\norganization level. In order for Config Connector to determine where to create\nyour resources, it first checks for a [scope-defining field](/config-connector/docs/how-to/organizing-resources/overview#scope-defining_field)\nin your resource spec, if not found, then checks for a [scope-defining annotation](/config-connector/docs/how-to/organizing-resources/overview#scope-defining_annotation).\n| **Note:** The scope concept does not apply to all Config Connector resources. See [Exceptions](/config-connector/docs/how-to/organizing-resources/overview#exceptions) for more details. You can check the [resource reference page](/config-connector/docs/reference/resources) to see if a resource supports the `spec.folderRef` field or `cnrm.cloud.google.com/folder-id` annotation.\n\nSpecify `folderRef` field\n-------------------------\n\nMost folder-scoped Config Connector resources support a field named `folderRef`\nin its CRD spec. Use this field to specify the Google Cloud folder you\nwant to create the resource in.\n\nIf the Google Cloud folder is also being managed in the same cluster via\nthe [Folder](/config-connector/docs/reference/resource-docs/resourcemanager/folder)\nCRD, you can specify the folder as a Kubernetes resource reference: \n\n ...\n spec:\n folderRef:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFOLDER_RESOURCE_NAME\u003c/span\u003e\u003c/var\u003e\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFOLDER_RESOURCE_NAMESPACE\u003c/span\u003e\u003c/var\u003e\n ...\n\nThis approach makes it possible to use Config Connector and create a Google Cloud\nfolder with its child resources in one single apply operation.\nThe namespace field is optional if the Config Connector Folder resource is in\nthe same Kubernetes namespace as your folder-scoped resource.\n\nIf the Google Cloud folder is not being managed as a Kubernetes resource\nin the same cluster, you can use the `external` field to directly specify the\nfolder ID. The exact format of the value may be different depending on the\nresource type. Two most common formats are \"\u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e\" and\n\"folders/\u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e\". See an example of \"\u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e\" below: \n\n ...\n spec:\n folderRef:\n external: \"\u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e\"\n ...\n\nAnnotate resource configuration\n-------------------------------\n\nIf the Config Connector resource is folder-scoped but does not support the\n`folderRef` field, you can set the folder ID to the resource configuration\nusing the `folder-id` annotation: \n\n ...\n metadata:\n annotations:\n cnrm.cloud.google.com/folder-id: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFOLDER_ID\u003c/span\u003e\u003c/var\u003e\n ...\n\nHere is an example of what a resource's YAML will look like with this annotation\nin it: \n\n apiVersion: foo.cnrm.cloud.google.com/v1beta1\n kind: FooBar\n metadata:\n annotations:\n cnrm.cloud.google.com/folder-id: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFOLDER_ID\u003c/span\u003e\u003c/var\u003e\n name: foobarname\n\nAnnotate namespace configuration\n--------------------------------\n\nYou can set a default folder ID for newly-created resources by\nannotating your Kubernetes namespace. If any of the resources in the namespace\nhave this annotation explicitly set in its own configuration, the resource-level\nannotation overwrites the namespace-level annotation.\n\nTo annotate the namespace using command line, run the following command: \n\n```\nkubectl annotate namespace NAMESPACE_NAME cnrm.cloud.google.com/folder-id=FOLDER_ID\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e: your namespace name\n- \u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e: your Google Cloud folder ID\n\nAlternatively, you can apply a YAML manifest containing the annotation.\nCopy the YAML below into a file: \n\n apiVersion: v1\n kind: Namespace\n metadata:\n annotations:\n cnrm.cloud.google.com/folder-id: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFOLDER_ID\u003c/span\u003e\u003c/var\u003e\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eNAMESPACE_NAME\u003c/span\u003e\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e: your Google Cloud folder ID\n- \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e: your namespace name\n\nAfter you have created the file, apply it to your cluster.\n| **Note:** You must create the namespace and annotation before applying any resources into the namespace."]]