Halaman ini menunjukkan cara memberikan akses Binary Authorization ke kebijakan dan image penampung yang ada di project Google Cloud lain daripada project Anda saat ini. Misalnya, jika Anda men-deploy image di cluster Google Kubernetes Engine (GKE) dari repositori Artifact Registry atau Container Registry (Tidak digunakan lagi) yang dimiliki oleh project lain, Anda harus memberikan akses layanan Otorisasi Biner di project Anda ke metadata image di repositori sumber.
Terminologi
Dokumen ini menggunakan istilah berikut:
- Agen layanan: Akun layanan yang dikelola A Google Cloud. Otorisasi Biner menggunakan agen layanan untuk berinteraksi dengan resource Google Cloud Anda, seperti cluster GKE.
- Project kebijakan: Project Google Cloud yang berisi kebijakan Otorisasi Biner Anda.
- Project cluster: Project Google Cloud yang berisi cluster GKE Anda.
- Project artefak: Project Google Cloud yang berisi repositori Artifact Registry atau Container Registry (Tidak digunakan lagi) Anda.
Skenario yang memerlukan akses lintas project
Anda harus memberikan izin lintas project dalam situasi seperti berikut:
- Project kebijakan Anda berbeda dengan project cluster Anda.
- Project cluster Anda berbeda dengan project artefak Anda.
Sebelum memulai
- 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.
-
Install the Google Cloud CLI.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Binary Authorization API:
gcloud services enable binaryauthorization.googleapis.com
-
Install the Google Cloud CLI.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Binary Authorization API:
gcloud services enable binaryauthorization.googleapis.com
POLICY_PROJECT_ID
: ID project yang berisi kebijakan Anda.CLUSTER_PROJECT_ID
: project ID cluster.ARTIFACT_PROJECT_ID
: ID project yang berisi repositori Artifact Registry Anda.CLUSTER_PROJECT_ID
: project ID yang menjalankan cluster GKE Anda.
Project cluster berbeda dengan project kebijakan
Beri agen layanan Otorisasi Biner di project cluster peran
Binary Authorization Policy Evaluator
(roles/binaryauthorization.policyEvaluator
)
di project kebijakan.
gcloud projects add-iam-policy-bindingPOLICY_PROJECT_ID
\ --member="serviceAccount:service-$(gcloud projects describeCLUSTER_PROJECT_ID
--format='value(projectNumber)')@gcp-sa-binaryauthorization.iam.gserviceaccount.com" \ --role=roles/binaryauthorization.policyEvaluator
Ganti kode berikut:
Project cluster berbeda dengan project artefak
Beri agen layanan Otorisasi Biner di project cluster peran
Artifact Registry Reader
(roles/artifactregistry.reader
) di project artefak.
gcloud projects add-iam-policy-bindingARTIFACT_PROJECT_ID
\ --member="serviceAccount:service-$(gcloud projects describeCLUSTER_PROJECT_ID
--format='value(projectNumber)')@gcp-sa-binaryauthorization.iam.gserviceaccount.com" \ --role=roles/artifactregistry.reader
Ganti kode berikut: