Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the minimal permissions I need to configure for a GKE node pool to pull from a private GCR repo in the same project?

I am trying to configure my GKE cluster to pull from a private GCR repo in the same project. I am not using OAuth scopes but have associated a least privilege service account with the default node pool and provided it with the roles/storage.objectViewer permission.

However, I am still receiving the following when trying to access this image: Failed to pull image "eu.gcr.io/<project>/<image>": rpc error: code = Unknown desc = Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication

Do I also need to configure imagePullSecrets or should the roles/storage.objectViewer permission be sufficient?

like image 934
dippynark Avatar asked Oct 26 '18 11:10

dippynark


People also ask

What happens when you delete a node pool in GKE?

When you delete a node pool , GKE drains all the nodes in the node pool. The draining process involves GKE evicting Pods on each node in the node pool. Each node in a node pool is drained by evicting Pods with an allotted graceful termination period of MAX_POD.

What permissions should I configure for container registry in Google Cloud?

Google Cloud services that typically access Container Registry are configured with default permissions to registries in the same Google Cloud project. If the default permissions don't meet your needs, you must configure the appropriate permissions.

How do node pools work in Kubernetes Engine (GKE)?

This page explains how node pools work in Google Kubernetes Engine (GKE). To learn how to manage node pools, see Adding and managing node pools. A node pool is a group of nodes within a cluster that all have the same configuration.

Can I grant permissions on a repository within a registry?

You cannot grant permissions on repositories within a registry. If you need more granular access control, Artifact Registry provides repository-level access control and might better suit your needs.


1 Answers

The root cause of this issue was not setting access (OAuth) scopes on the cluster instances preventing the service account from working as intended.

From the GCP docs about Compute service accounts :

You must set access scopes on the instance to authorize access.

You cannot set only IAM roles on the service account and omit access scopes when creating the virtual machine instance. The level of access a service account has is determined by a combination of access scopes and IAM roles so you must configure both access scopes and IAM roles for the service account to work properly.

The minimal scopes required when accessing private images in GCR can be found here with the meaning of these scopes found here. A least privilege service account for the cluster nodes can then be created following the instructions here.

As described here an alternative would be to only grant the https://www.googleapis.com/auth/cloud-platform scope to the cluster nodes which authorises access to all Cloud Platform services and then limit access through IAM roles on node service accounts.

By configuring the cluster nodes as above, imagePullSecrets are not required for pulling private images from GCR in the same project.

like image 151
dippynark Avatar answered Sep 19 '22 23:09

dippynark