Skip to main content

More Info:

Configure the Cluster Service Account with Storage Object Viewer Role to only allow readonly access to GCR.

Risk Level

Medium

Address

Best Practice, Reliability, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CIS GKE
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To minimize cluster access to read-only for GCR in GCP, you can follow the below steps:
  1. Open the Google Cloud Console and select the GKE cluster for which you want to minimize the access.
  2. Click on the “Edit” button for the cluster.
  3. Scroll down to the “Security” section and click on “Add item” under the “Container Registry” subsection.
  4. In the “Add members” field, enter the email addresses of the users or service accounts that you want to grant read-only access to.
  5. In the “Role” field, select “Storage Object Viewer” from the dropdown menu.
  6. Click on the “Save” button to save the changes.
  7. Repeat steps 4-6 for each user or service account that you want to grant read-only access to.
  8. Once you have added all the users or service accounts, click on the “Save” button to save the changes to the cluster.
By following these steps, you will be able to minimize the cluster access to read-only for GCR in GCP using the GCP console.

To minimize cluster access to read-only for GCR, you can follow these steps:
  1. Open the Cloud Shell in your GCP console.
  2. Run the following command to create a new Kubernetes cluster role:
  3. Run the following command to create a new Kubernetes cluster role binding:
    Replace <your-email-address> with your GCP account email address.
  4. Run the following command to grant the Kubernetes service account read-only access to the Google Container Registry:
    Replace <your-project-id> with your GCP project ID.
  5. Run the following command to verify that the Kubernetes service account has read-only access to the Google Container Registry:
    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.
To minimize cluster access to read-only for GCR in GCP, you can follow these steps:
  1. Open the Cloud Shell in your GCP console.
  2. Install the necessary Python libraries by running the following command:
  3. Create a Python script and import the necessary libraries:
  4. Set up the credentials for your GCP account:
  5. Create a storage client using the credentials:
  6. Get the bucket that contains your GCR images:
  7. Set the bucket’s IAM policy to allow read-only access for the cluster:
    Note: Replace my-cluster-sa@my-project.iam.gserviceaccount.com with the service account of your cluster.
  8. Save the Python script and run it using the following command:
This will minimize cluster access to read-only for GCR in GCP.
This change does not force replacement of the cluster or the service account; it only adds an IAM binding.Verification: terraform plan should show one new google_project_iam_member.gke_gcr_readonly to be added with role = "roles/storage.objectViewer" and member = "serviceAccount:...@...iam.gserviceaccount.com".

Additional Reading: