Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina mostra come concedere l'accesso all'autorizzazione binaria a criteri e immagini container che esistono in progetti Google Cloud diversi dal tuo progetto attuale.
Ad esempio, se esegui il deployment di immagini nel cluster Google Kubernetes Engine (GKE)
da un repository Artifact Registry o Container Registry (ritirato)
di proprietà di un altro progetto, devi concedere al servizio di autorizzazione binaria nel tuo progetto l'accesso ai metadati dell'immagine nel repository di origine.
Terminologia
Questo documento utilizza i seguenti termini:
Agente di servizio : account di servizio gestito da Google Cloud.
Autorizzazione binaria utilizza un service agent per interagire con le tue risorse, come i cluster GKE. Google Cloud
Progetto policy: il progetto che contiene la policy di autorizzazione binaria. Google Cloud
Progetto cluster: il progetto Google Cloud che contiene il tuo
cluster GKE.
Progetto artefatto : il progetto Google Cloud che contiene il tuo repository Artifact Registry o Container Registry (deprecato).
Scenari che richiedono l'accesso tra progetti
Devi concedere le autorizzazioni tra progetti in situazioni come le seguenti:
Il progetto delle norme è diverso dal progetto del cluster.
Il progetto del cluster è diverso dal progetto dell'artefatto.
Prima di iniziare
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
Il progetto del cluster è diverso dal progetto del criterio
Concedi all'agente di servizio Autorizzazione binaria nel progetto cluster il ruolo
Valutatore del criterio di autorizzazione binaria
(roles/binaryauthorization.policyEvaluator)
nel progetto dei criteri.
POLICY_PROJECT_ID: l'ID del progetto che contiene la policy.
CLUSTER_PROJECT_ID: l'ID progetto del cluster.
Progetto cluster diverso dal progetto artefatto
Concedi all'agente di servizio Autorizzazione binaria nel progetto cluster il ruolo
Lettore Artifact Registry
(roles/artifactregistry.reader) nel progetto artefatto.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis document guides users on granting Binary Authorization access across different Google Cloud projects for policies and container images.\u003c/p\u003e\n"],["\u003cp\u003eCross-project access is required when the policy project, cluster project, and artifact project are not the same.\u003c/p\u003e\n"],["\u003cp\u003eThe Binary Authorization service agent in the cluster project needs the \u003ccode\u003eroles/binaryauthorization.policyEvaluator\u003c/code\u003e role on the policy project.\u003c/p\u003e\n"],["\u003cp\u003eThe Binary Authorization service agent in the cluster project needs the \u003ccode\u003eroles/artifactregistry.reader\u003c/code\u003e role on the artifact project.\u003c/p\u003e\n"],["\u003cp\u003eIf using Container Registry, the \u003ccode\u003eroles/storage.objectViewer\u003c/code\u003e role can be used instead, but migrating to Artifact Registry is recommended because Container Registry is deprecated.\u003c/p\u003e\n"]]],[],null,["# Configure cross-project access in GKE\n\nThis page shows you how to give Binary Authorization access to policies and container\nimages that exist in different Google Cloud projects than your current project.\nFor example, if you deploy images in your Google Kubernetes Engine (GKE) cluster\nfrom an Artifact Registry or Container Registry ([Deprecated](/container-registry/docs/deprecations/container-registry-deprecation))\nrepository that's owned by a different project, you'll need to give the\nBinary Authorization service in your project access to the image metadata in\nthe source repository.\n\nTerminology\n-----------\n\nThis document uses the following terms:\n\n- **Service agent:**A Google Cloud-managed service account. Binary Authorization uses a service agent to interact with your Google Cloud resources, like GKE clusters.\n- **Policy project:**The Google Cloud project that contains your Binary Authorization policy.\n- **Cluster project:**The Google Cloud project that contains your GKE cluster.\n- **Artifact project:** The Google Cloud project that contains your Artifact Registry or Container Registry ([Deprecated](/container-registry/docs/deprecations/container-registry-deprecation)) repository.\n\nScenarios that require cross-project access\n-------------------------------------------\n\nYou must grant cross-project permissions in situations like the following:\n\n- Your policy project is different than your cluster project.\n- Your cluster project is different than your artifact project.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Binary Authorization API:\n\n\n ```bash\n gcloud services enable binaryauthorization.googleapis.com\n ```\n\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Binary Authorization API:\n\n\n ```bash\n gcloud services enable binaryauthorization.googleapis.com\n ```\n\n\u003cbr /\u003e\n\nCluster project different than the policy project\n-------------------------------------------------\n\nGrant the Binary Authorization service agent in the cluster project the\n[Binary Authorization Policy Evaluator](/iam/docs/understanding-roles#binaryauthorization.policyEvaluator)\n(`roles/binaryauthorization.policyEvaluator`)\nrole on the policy project. \n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePOLICY_PROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:service-$(gcloud projects describe \u003cvar translate=\"no\"\u003eCLUSTER_PROJECT_ID\u003c/var\u003e --format='value(projectNumber)')@gcp-sa-binaryauthorization.iam.gserviceaccount.com\" \\\n --role=roles/binaryauthorization.policyEvaluator\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePOLICY_PROJECT_ID\u003c/var\u003e: the ID of the project that contains your policy.\n- \u003cvar translate=\"no\"\u003eCLUSTER_PROJECT_ID\u003c/var\u003e: the project ID of the cluster.\n\n\u003cbr /\u003e\n\nCluster project different than the artifact project\n---------------------------------------------------\n\nGrant the Binary Authorization service agent in the cluster project the\n[Artifact Registry Reader](/iam/docs/understanding-roles#artifactregistry.reader)\n(`roles/artifactregistry.reader`) role on the artifact project. \n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003eARTIFACT_PROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:service-$(gcloud projects describe \u003cvar translate=\"no\"\u003eCLUSTER_PROJECT_ID\u003c/var\u003e --format='value(projectNumber)')@gcp-sa-binaryauthorization.iam.gserviceaccount.com\" \\\n --role=roles/artifactregistry.reader\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eARTIFACT_PROJECT_ID\u003c/var\u003e: the ID of the project that contains your Artifact Registry repository. **Note:** If you use Container Registry, you can use the [Storage Object Viewer](/iam/docs/understanding-roles#storage.objectViewer) (`roles/storage.objectViewer`) role, but we recommend that you migrate to Artifact Registry. Container Registry is deprecated. For migration instructions, see [Transition from Container Registry](/artifact-registry/docs/transition/transition-from-gcr).\n- \u003cvar translate=\"no\"\u003eCLUSTER_PROJECT_ID\u003c/var\u003e: the project ID that runs your GKE clusters.\n\n\u003cbr /\u003e"]]