Replace <your-project-id> with your GCP project ID.
Run the following command to verify that the Kubernetes service account has read-only access to the Google Container Registry:
Copy
Ask AI
gcloud auth activate-service-account --key-file=/var/run/secrets/kubernetes.io/serviceaccount/tokengcloud container images list
This will list all the images in your project’s Google Container Registry. If you can see the list of images, it means that the Kubernetes service account has read-only access to the Google Container Registry.
By following these steps, you have minimized cluster access to read-only for GCR in GCP using GCP CLI.
Using Python
To minimize cluster access to read-only for GCR in GCP, you can follow these steps:
Open the Cloud Shell in your GCP console.
Install the necessary Python libraries by running the following command:
Copy
Ask AI
pip install google-cloud-storage google-auth
Create a Python script and import the necessary libraries:
Copy
Ask AI
from google.cloud import storagefrom google.oauth2 import service_account