이 페이지에서는 구성 커넥터가 충돌을 처리하는 방법을 설명합니다. 충돌은 동일한 리소스가 여러 리소스에서 관리될 때 발생할 수 있습니다.
Config Connector는 Kubernetes 리소스 이름, 컨테이너 주석 및 해당되는 경우 리전 또는 위치의 조합을 매핑하여 리소스를 관리 또는 획득합니다. 가장 간단한 사례에서는 Google Cloud 프로젝트를 사용하여 리소스를 구성합니다.
Google Cloud는 프로젝트 범위를 넘어 추가적인 계층 구조 수준(폴더, 프로젝트, 조직)을 지원합니다. 주석으로 폴더, 프로젝트, 조직에 리소스를 매핑할 수 있습니다. Config Connector를 사용하여 주석 없이 리소스를 만들 때는 리소스의 네임스페이스를 공유하는 프로젝트에 리소스가 생성됩니다.
동일한 Google Cloud 리소스를 관리하는 다른 네임스페이스에 두 개의 Config Connector 리소스를 만들 수는 있지만 권장하지는 않습니다.
Config Connector는 Google Cloud 리소스에 대한 임대를 얻을 수 있고 충돌 방지가 사용 설정된 경우에만 해당 Google Cloud 리소스를 관리합니다.
임대는 네임스페이스 범위입니다. 네임스페이스 범위 임대를 얻기 위해 Config Connector는 리소스에 다음 두 개의 라벨을 추가합니다.
cnrm-lease-holder-id: 구성 컨트롤러는 충돌 방지가 사용 설정된 리소스를 관리하는 각 네임스페이스에 대해 고유 ID를 생성합니다. 이 고유 ID는 cnrm-lease-holder-id를 설정하기 위해 사용됩니다. cnrm-lease-holder-id 값에 대한 네임스페이스 매핑을 보려면 cnrm-system 네임스페이스에서 namespace-id ConfigMap을 참조할 수 있습니다.
다음 중 하나에 해당하면 Config Connector는 이러한 값을 업데이트할 수 있습니다.
cnrm-lease-holder-id의 값은 네임스페이스의 전역 고유 ID와 일치합니다.
cnrm-lease-holder-id의 값이 비어 있거나 존재하지 않습니다.
cnrm-lease-expiration의 값이 이전 시점에 있습니다.
Config Connector 인스턴스가 리소스 임대를 획득하면 만료 시간은 향후 40분으로 설정됩니다. 리소스가 네임스페이스에 있는 한 Config Connector의 동일한 인스턴스는 관리를 유지합니다. 남은 시간이 20분 미만이면 Config Connector는 만료 시간을 40분 연장합니다.
Config Connector가 해당 리소스에 대한 임대를 확보할 수 없는 경우, 리소스에 대한 kubectl describe의 출력에 ManagementConflict 상태로 표시됩니다.
충돌 방지 수정
다음 값 중 하나를 사용하여 cnrm.cloud.google.com/management-conflict-prevention-policy 주석을 리소스에 추가하여 충돌 방지를 제어할 수 있습니다.
resource: 이전 섹션에서 설명한 대로 적절한 임대 라벨을 리소스에 저장하여 리소스 수준에서 관리 충돌이 방지됩니다.
none: 관리 충돌이 방지되지 않습니다.
기본값은 none입니다.
다음 예시에서 기본 ComputeNetwork의 매니페스트는 none의 관리 정책을 사용하므로 충돌이 방지되지 않습니다.
apiVersion:compute.cnrm.cloud.google.com/v1beta1kind:ComputeNetworkmetadata:annotations:cnrm.cloud.google.com/management-conflict-prevention-policy:"none"cnrm.cloud.google.com/project-id:"PROJECT-ID"cnrm.cloud.google.com/deletion-policy:"abandon"name:defaultspec:description:Default network for the project
제한사항
충돌 방지에는 다음과 같은 제한사항이 있습니다.
중요: 라벨을 지원하지 않는 리소스에는 충돌 방지가 작동하지 않습니다. 값을 none에서 resource로 변경하더라도 작동하지 않습니다.
resourceID 필드로 리소스를 관리하는 경우 동일한 네임스페이스로 생성된 동일한 Google Cloud 리소스 이름으로 여러 리소스를 만들 수 있습니다. 이러한 리소스로 인해 Config Connector가 관리할 수 없는 충돌이 발생합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["\u003cp\u003eConfig Connector manages Google Cloud resources by mapping Kubernetes resource names, container annotations, and optionally, region or location.\u003c/p\u003e\n"],["\u003cp\u003eConflicts can arise when multiple Config Connector resources attempt to manage the same Google Cloud resource, which Config Connector handles through a leasing system.\u003c/p\u003e\n"],["\u003cp\u003eLeases are namespace-scoped and are managed using two labels, \u003ccode\u003ecnrm-lease-holder-id\u003c/code\u003e and \u003ccode\u003ecnrm-lease-expiration\u003c/code\u003e, ensuring only one Config Connector instance manages a resource at any given time.\u003c/p\u003e\n"],["\u003cp\u003eConflict prevention can be controlled using the \u003ccode\u003ecnrm.cloud.google.com/management-conflict-prevention-policy\u003c/code\u003e annotation with values of \u003ccode\u003eresource\u003c/code\u003e (prevent conflicts) or \u003ccode\u003enone\u003c/code\u003e (do not prevent conflicts), defaulting to \u003ccode\u003enone\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eConflict prevention has limitations, including not working with resources that do not support labels and when managing multiple resources with the same name in the same namespace using resource IDs.\u003c/p\u003e\n"]]],[],null,["# Managing conflicts with multiple Config Connector resources\n===========================================================\n\n*** ** * ** ***\n\nThis page describes how Config Connector handles conflicts. Conflicts can happen\nwhen the same resource is managed by multiple resources.\n\nConfig Connector\n[manages or acquires](/config-connector/docs/how-to/managing-deleting-resources)\nresources by mapping the combination of Kubernetes resource name, container\nannotation, and if applicable, region or location. In the simplest case, you\norganize your resources with Google Cloud\n[projects](/resource-manager/docs/cloud-platform-resource-hierarchy#projects).\n\nGoogle Cloud supports additional levels of hierarchy beyond projects:\nfolders, projects, and organizations. You can map resources to your\n[folders, projects, and organizations](/config-connector/docs/how-to/organizing-resources/overview)\nwith an annotation. When you create a resource without an annotation using\nConfig Connector, the resource is created in the project that shares the\nresource's namespace.\n\nIt is possible, but not recommended, to create two Config Connector resources\nin different namespaces that manage the same Google Cloud resource.\nConfig Connector only manages the corresponding Google Cloud resource if\nit is able to obtain a lease on the Google Cloud resource and conflict\nprevention is [enabled](#modifying_conflict_prevention).\n\nLeases are namespace-scoped. To obtain a namespace-scoped lease, Config Connector\nadds two labels to the resource:\n\n1. `cnrm-lease-holder-id`: Config Controller generates a unique ID for each namespace that manages a resource with conflict prevention enabled. This unique ID is what's used to set `cnrm-lease-holder-id`. To see the mapping of the namespace to the `cnrm-lease-holder-id` value, you can look at the `namespace-id` ConfigMap in the `cnrm-system` namespace.\n2. `cnrm-lease-expiration`: An expiration time in [Unix epoch time](https://en.wikipedia.org/wiki/Unix_time).\n\nConfig Connector is able to update these values if any of the following is\ntrue:\n\n- The value of `cnrm-lease-holder-id` matches the namespace's globally unique ID.\n- The value of `cnrm-lease-holder-id` is empty or non-existent.\n- The value of `cnrm-lease-expiration` is in the past.\n\nWhen a Config Connector instance obtains a lease on a resource, the expiration\ntime is set to 40 minutes in the future. The same instance of Config Connector\nretains management as long as the resource is in the namespace. Config Connector\nextends the expiration time by 40 minutes when less than 20 minutes remain.\n\nIf Config Connector is unable to obtain a lease on a given resource, the output\nof\n[`kubectl describe`](/config-connector/docs/how-to/get-resource-info#describing_a_resource)\non the resource lists a Status of `ManagementConflict`.\n\nModifying conflict prevention\n-----------------------------\n\nYou can control conflict prevention by adding the\n`cnrm.cloud.google.com/management-conflict-prevention-policy` annotation to the\nresource with one of the following values:\n\n- `resource`: management conflicts are prevented at the resource level by saving the appropriate lease labels into the resource as described in the preceding section.\n- `none`: management conflicts are not prevented.\n\nThe default value is `none`.\n\nIn the following example, a manifest for the default ComputeNetwork uses a\nmanagement policy of `none`, which means that conflicts are not prevented: \n\n apiVersion: compute.cnrm.cloud.google.com/v1beta1\n kind: ComputeNetwork\n metadata:\n annotations:\n cnrm.cloud.google.com/management-conflict-prevention-policy: \"none\"\n cnrm.cloud.google.com/project-id: \"\u003cvar translate=\"no\"\u003ePROJECT-ID\u003c/var\u003e\"\n cnrm.cloud.google.com/deletion-policy: \"abandon\"\n name: default\n spec:\n description: Default network for the project\n\nLimitations\n-----------\n\nConflict prevention has the following limitations:\n\n- Conflict prevention does not work for resources that don't support\n labels. Even if you change the value from `none` to `resource`, it still\n doesn't work.\n\n- If you are\n [Managing resources with the resourceID field](/config-connector/docs/how-to/managing-resources-with-resource-ids)\n you can create multiple resources with the same Google Cloud resource name,\n created under the same namespace. These resources create conflicts that\n Config Connector cannot manage."]]