resource"google_gke_hub_feature_membership""feature_member"{provider=google-betalocation="global"feature="configmanagement"membership=google_gke_hub_membership.membership.membership_idconfigmanagement{version="1.8.0"config_sync{source_format="unstructured"git{}} # if you're still using the config_sync block, delete only the policy_controller blockpolicy_controller{enabled=truetemplate_library_installed=truereferential_rules_enabled=true}}}
[[["易于理解","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-08-31。"],[],[],null,["# Migrate from the ConfigManagement API to the PolicyController API\n\nThis page explains how to migrate from the `ConfigManagement` API\nto the `PolicyController` API for managing Policy Controller.\nThe `PolicyController` API offers the same capabilities for installing and\nmanaging Policy Controller.\n\nStarting in April, 2025, the `configManagement` API version 1.21 and later\nno longer supports Policy Controller installation or updates. Attempting to upgrade\nor install Policy Controller with this method will fail with an error. Follow the\ninstructions on this page to migrate so that you can continue\nusing Policy Controller.\n\nThe steps to fully migrate differ depending on which installation method\nyou used to install Policy Controller.\n\nIf you use gcloud CLI `PolicyController` commands that start with\n`gcloud container fleet policycontroller`, you are already using the `PolicyController`\nAPI. No action is needed. Otherwise, review the instructions for the method\nthat you used to install Policy Controller: \n\n### `config management`\n\nIf you use gcloud CLI commands that start with `gcloud alpha container fleet config-management`,\nswitch to using gcloud CLI Policy Controller commands that start\nwith `gcloud container fleet policycontroller`. Review the\n[gcloud CLI documentation](/sdk/gcloud/reference/container/fleet/policycontroller)\nfor a list of commands. No other action is required.\n\nIf your [Google Cloud CLI `apply spec` file](/kubernetes-engine/enterprise/config-sync/docs/reference/gcloud-apply-fields#policy_controller)\nhas the `policyController` block, remove it to ensure compatibility with\nConfig Sync.\n\n### Terraform\n\nIf you use a Terraform resource that configures Policy Controller with the\n[feature name `\"configmanagement\"`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership),\nyou should switch to a Terraform resource with the feature name `\"policycontroller\"`\nby completing the following steps:\n\n1. Copy your existing Terraform file to a new file, or update your Terraform file, and add the following:\n\n resource \"google_gke_hub_feature\" \"feature\" {\n name = \"policycontroller\"\n location = \"global\"\n }\n\n resource \"google_gke_hub_feature_membership\" \"feature_member\" {\n feature = google_gke_hub_feature.feature.name # \"policycontroller\"\n location = \"global\"\n membership = \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-err\"\u003eMEMBERSHIP_NAME\u003c/span\u003e\u003c/var\u003e\n project = \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-err\"\u003ePROJECT_ID\u003c/span\u003e\u003c/var\u003e\n policycontroller {\n policy_controller_hub_config {\n install_spec = \"INSTALL_SPEC_ENABLED\"\n }\n }\n }\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eMEMBERSHIP\u003c/var\u003e: the membership name of the registered cluster that has Policy Controller installed.\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID.\n2. Remove the `\"policy_controller\"` block from your existing Terraform resource.\n You can find the block under the `\"configmanagement\"` block.\n If you're using the resource to *only* manage Policy Controller,\n you can remove the entire `configmanagement` block. If you're using the\n resource to manage Config Sync, ensure you remove only the Policy Controller\n block. For example, your `configmanagement` block might resemble the\n following:\n\n resource \"google_gke_hub_feature_membership\" \"feature_member\" {\n provider = google-beta\n location = \"global\"\n feature = \"configmanagement\"\n membership = google_gke_hub_membership.membership.membership_id\n configmanagement {\n version = \"1.8.0\"\n config_sync {\n source_format = \"unstructured\"\n git {\n }\n }\n # if you're still using the config_sync block, delete only the policy_controller block\n policy_controller {\n enabled = true\n template_library_installed = true\n referential_rules_enabled = true\n }\n }\n }\n\n3. [Import the Policy Controller membership feature settings](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature#import)\n by completing one of the following steps:\n\n 1. Run the following command:\n\n terraform import \"google_gke_hub_feature.feature\" \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/features/policycontroller\"\n terraform import \"google_gke_hub_feature_membership.feature_member\" \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/features/policycontroller/membershipId/\u003cvar translate=\"no\"\u003eMEMBERSHIP_NAME\u003c/var\u003e\"\n\n 2. Add an [import block](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership#import) to your Terraform resource:\n\n import {\n to = google_gke_hub_feature_membership.feature_member\n id = \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/features/policycontroller/membershipId/\u003cvar translate=\"no\"\u003eMEMBERSHIP_NAME\u003c/var\u003e\"\n }\n import {\n to = google_gke_hub_feature.feature\n id = \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/features/policycontroller\"\n }\n\n4. Apply the Policy Controller settings:\n\n terraform apply\n\n5. Optional: After the import is complete, you can\n remove the import block from your Terraform resource. Alternatively,\n it is safe to leave the import block in your configuration as a record of\n the resource's origin.\n\n### Config Connector\n\nTo stop using the `configmanagement.policyController` spec, complete the\nfollowing steps:\n\n1. Create a new [`GKEHubFeatureMembership` spec](/config-connector/docs/reference/resource-docs/gkehub/gkehubfeaturemembership)\n with the required `policycontroller` fields. Ensure that you set the `resourceID` field to `policyController`.\n\n2. If you have an existing `GKEHubFeatureMembership` that uses the `spec.configmanagement.policyController` field,\n remove any `policycontroller` fields from the `configmanagement` spec.\n\n### kubectl\n\nIf you use `kubectl` commands to manage Policy Controller with a `ConfigManagement`\nobject, switch to using gcloud CLI Policy Controller commands that start\nwith `gcloud container fleet policycontroller`. No other action is required.\n\nIf your [`ConfigManagement` object](/kubernetes-engine/enterprise/config-sync/docs/configmanagement-fields#integrations)\nhas the `policyController` block, remove it for compatibility with Config Sync.\n\nYou might want to review the following resources to learn more about the\nPolicy Controller API:\n\n- [Install Policy Controller with `gcloud container fleet policycontroller` commands](/kubernetes-engine/enterprise/policy-controller/docs/how-to/installing-policy-controller#gcloud-policycontroller)\n- Review the [Config Connector `GKEHubFeature` reference documentation](/config-connector/docs/reference/resource-docs/gkehub/gkehubfeature)\n- Review the [Terraform `google_gke_hub_feature` reference documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_featureP)"]]