조직 정책 API는 Kubernetes 커스텀 리소스를 사용하고 Kubernetes 리소스 모델 (KRM)을 기반으로 합니다. 생성, 업데이트, 삭제와 같은 조직 정책의 수명 주기를 관리하는 데 사용됩니다.
조직 정책 API를 사용하려면 Kubernetes CLI kubectl를 사용하는 것이 좋습니다. 애플리케이션에서 자체 라이브러리를 사용하여 이 API를 호출해야 하는 경우 다음 예시, 전체 API 정의, 전용 정책 일치 페이지를 사용하여 요청을 빌드하세요.
서비스 엔드포인트 및 검색 문서
조직 정책 API의 API 엔드포인트는 다음과 같습니다.
https://MANAGEMENT_API_SERVER_ENDPOINT/apis/constraints.gatekeeper.sh/v1beta1
여기서 MANAGEMENT_API_SERVER_ENDPOINT는 관리 API 서버의 엔드포인트입니다.
kubectl proxy 명령어를 사용하여 브라우저에서 또는 curl과 같은 도구로 해당 URL에 액세스하여 조직 정책 API의 검색 문서를 가져올 수 있습니다. kubectl proxy 명령어는 로컬 머신에서 Kubernetes API 서버로의 프록시를 엽니다. 명령어가 실행되면 다음 URL에서 문서에 액세스할 수 있습니다.
http://127.0.0.1:8001/apis/constraints.gatekeeper.sh/v1beta1
KRM 예
다음 예는 조직 정책 API에서 데이터베이스 서비스 사용을 owner: dba-team 라벨이 있는 프로젝트로 제한하는 GDCHRestrictedServices 객체입니다.
apiVersion:constraints.gatekeeper.sh/v1beta1kind:GDCHRestrictedServicemetadata:name:db-restricted-to-dbasspec:match:scope:NamespacednamespaceSelector:matchExpressions:# We are restricting the use of the service in namespaces that# DON'T have the owner: dba-team label-key:owneroperator:NotInvalues:-dba-teamkinds:-apiGroups:-"postgresql.ods.anthosapis.com"kinds:-Dbclusters-Backupplans-Imports-Restores-apiGroups:-"oracle.ods.anthosapis.com"kinds:-Dbclusters-Backupplans-Importsparameters:disabledOperations:-"UPDATE"-"CREATE"
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThe Organization Policy API uses Kubernetes custom resources and the Kubernetes Resource Model (KRM) to manage the lifecycle of organization policies.\u003c/p\u003e\n"],["\u003cp\u003eIt is recommended to use the Kubernetes CLI \u003ccode\u003ekubectl\u003c/code\u003e to interact with the Organization Policy API, but alternative methods are available using the provided API definition.\u003c/p\u003e\n"],["\u003cp\u003eThe API endpoint is located at \u003ccode\u003ehttps://<GDCH_API_SERVER_ENDPOINT>/apis/constraints.gatekeeper.sh/v1beta1\u003c/code\u003e, with a discovery document accessible via \u003ccode\u003ekubectl proxy\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAn example of the API is shown that uses the \u003ccode\u003eGDCHRestrictedServices\u003c/code\u003e object to restrict the use of the database service to namespaces that have the \u003ccode\u003eowner: dba-team\u003c/code\u003e label.\u003c/p\u003e\n"]]],[],null,["# Organization Policy API overview\n\nThe Organization Policy API uses Kubernetes custom resources and relies on the\nKubernetes Resource Model (KRM). It is used to manage the lifecycle of\norganization policies such as creating, updating, deleting.\n\nTo use the Organization Policy API, we recommend that you use the Kubernetes CLI\n`kubectl`. If your application needs to use its own libraries to call this API,\nuse the following example, the [full API definition](/distributed-cloud/hosted/docs/latest/appliance/apis/service/org-policy/org-policy-krm-api), and the\ndedicated [policy match page](/distributed-cloud/hosted/docs/latest/appliance/apis/service/org-policy/policy-match-section) to build your requests.\n| **Warning:** While organization policies leverage an open-source API that's marked as beta (`constraints.gatekeeper.sh/v1beta1`), the organization policy system itself is in alpha. Additional APIs may be introduced in the future to facilitate the management of organisation policies.\n\nService endpoint and discovery document\n---------------------------------------\n\nThe API endpoint for the Organization Policy API is:\n`https://`\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_ENDPOINT\u003c/var\u003e`/apis/constraints.gatekeeper.sh/v1beta1`\nwhere \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_ENDPOINT\u003c/var\u003e is the endpoint of the\nManagement API server.\n\nUsing the `kubectl proxy` command, you can access that URL in your browser or\nwith a tool such as `curl` to get the discovery document for the Organization\nPolicy API. The `kubectl proxy` command opens up a proxy to the Kubernetes API\nserver on your local machine. Once that command is running, you can access the\ndocument at the following URL:\n`http://127.0.0.1:8001/apis/constraints.gatekeeper.sh/v1beta1`.\n\nExample KRM\n-----------\n\nThe following example is a `GDCHRestrictedServices` object in the Organization\nPolicy API to restrict the use of the Database Service to projects that\nhave the label `owner: dba-team`. \n\n apiVersion: constraints.gatekeeper.sh/v1beta1\n kind: GDCHRestrictedService\n metadata:\n name: db-restricted-to-dbas\n spec:\n match:\n scope: Namespaced\n namespaceSelector:\n matchExpressions:\n # We are restricting the use of the service in namespaces that\n # DON'T have the owner: dba-team label\n - key: owner\n operator: NotIn\n values:\n - dba-team\n kinds:\n - apiGroups:\n - \"postgresql.ods.anthosapis.com\"\n kinds:\n - Dbclusters\n - Backupplans\n - Imports\n - Restores\n - apiGroups:\n - \"oracle.ods.anthosapis.com\"\n kinds:\n - Dbclusters\n - Backupplans\n - Imports\n parameters:\n disabledOperations:\n - \"UPDATE\"\n - \"CREATE\""]]