Prepare and test your skills

Prepare and test your skills

Repository Configuration and Deployment Manifests is the link between where container images are stored and where they run. Artifact Registry (opens in a new tab) stores container images in Docker-format repositories, and Google Kubernetes Engine (GKE) pulls those images when a Pod or Deployment lists the full image URI in YAML. A correct URI must include the location, project ID, repository name, image name, and tag.
Artifact Registry Docker repositories are separate storage locations for container images inside a Google Cloud project. Creating a repository is a separate operation from pushing or pulling images, and for all requests to the pkg.dev domain the repository must already exist. Repository names must be unique for each location in a project, and each repository is tied to one regional or multi-regional location.
A Docker repository is created with gcloud artifacts repositories create using --repository-format=docker and --location. The location controls where artifacts are stored, which affects latency, data transfer cost, and data residency. Optional settings include a description, encryption key, immutable tags, and vulnerability scanning.
The Artifact Registry image URI is the full path that identifies exactly where an image lives and which version to use. The format for Docker images is LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG. The hostname docker.pkg.dev identifies Docker-format repositories, while the prefix before it identifies the repository location.
The URI contains six parts that must match the repository and image:
LOCATION is the regional or multi-regional location of the repository, such as us-west1.docker.pkg.dev is the hostname for Docker-format repositories.PROJECT-ID is the Google Cloud project ID that contains the repository.REPOSITORY is the name of the repository where the image is stored.IMAGE is the image name, which can be different from the local image name.TAG is the version label, such as staging or v1. If no tag is specified, Docker applies the default latest tag.For example, us-west1-docker.pkg.dev/my-project/my-repo/test-image:staging refers to the staging version of test-image in the my-repo repository in location us-west1 and project my-project.
Exam tip: For pkg.dev URIs, the repository must be created before you push or pull; pushing the first image does not create it, and omitting :TAG pulls the latest tag.
Tagging and pushing prepares a local image so its name matches the Artifact Registry destination. The local Docker client tags a source image with the full URI, then pushes that tagged image from the client to the repository. Artifact Registry supports artifacts up to 5 TB and requires monolithic uploads rather than Docker chunked uploads.
The workflow moves data from the local machine to the repository in order:
AR_REGION-docker.pkg.dev.docker tag SOURCE-IMAGE LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG so the local image carries the full destination path.docker push LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG to upload the tagged image layers to the named repository.Kubernetes manifests reference Artifact Registry images through the container image field in Pod and Deployment YAML. In a Pod, the path flows from the manifest to the kubelet, which pulls the image from spec.containers[].image. In a Deployment, the same field appears under spec.template.spec.containers, and the Deployment controller creates Pods that each pull the listed image.
A Pod manifest sets apiVersion: v1, kind: Pod, and an image such as us-west1-docker.pkg.dev/example-project/hello-repo/hello-app:v1. A Deployment manifest sets apiVersion: apps/v1, kind: Deployment, replica count, selector labels, and the same style of image value with location, project, repository, image, and version. The configuration is applied to the cluster with kubectl apply -f YAML_FILE_NAME, and status is checked with commands such as kubectl get pod/hello-pod. When the URI is accurate, GKE resolves the location host, project, and repository and starts containers without requiring a separate registry host per image.
Authentication Mechanisms and Cross-Project Access describes how a GKE cluster proves its identity to Artifact Registry to pull container images. In the same Google Cloud project, pulls can rely on automatic node credentials, while pulls across projects or from external registries require explicit credentials. The choice depends on whether broad node-level access is enough or fine-grained workload identity is needed.
GKE authentication uses two different service account types with different boundaries. A Google Cloud service account belongs to a Google Cloud project and can be granted Identity and Access Management (IAM) permissions to clusters, namespaces, and any Google Cloud resource such as Artifact Registry. A Kubernetes service account belongs to a single cluster and is typically used only inside that cluster.
Because Google Cloud service accounts are more powerful, the security principle of least privilege says to use them only when their capabilities are required. To control detailed access inside the cluster, Google Kubernetes Engine (GKE) (opens in a new tab) uses Role-Based Access Control (RBAC) to define which operations and resources each identity can use:
Legacy Attribute Based Access Control should remain disabled so that Kubernetes RBAC and IAM are the sources of truth for authorization.
Node-level access means the Compute Engine instances that act as GKE nodes pull images using their attached Google Cloud service account. The kubelet process on each node sends the pull request from the node to Artifact Registry, and Artifact Registry checks the node service account's IAM permission on the repository. When the cluster and the registry are in the same project, this path works automatically because the nodes already carry a project identity with access to project resources.
This method is simple but broad, because every Pod scheduled on the same node pool shares the same node identity. GKE nodes run Container-Optimized OS by default, which hardens the node operating system, but it does not narrow which workloads can use the node credential. Choose node-level access when all workloads on the nodes need the same registry access and fine-grained separation is not required.
Workload Identity Federation for GKE is the method for letting a specific workload authenticate to Google Cloud APIs with its own IAM identity. It links a Kubernetes service account in a specific namespace to a Google Cloud service account, so traffic flows from the Pod to the Google Cloud API using the linked IAM identity instead of the shared node identity. The Google Cloud service account is then granted IAM permission on the Artifact Registry repository, while other workloads keep no access.
Setting up Workload Identity Federation for GKE follows an ordered sequence:
Before starting, the Google Kubernetes Engine API and the IAM Service Account Credentials API must be enabled, and the administrator needs roles/container.admin and roles/iam.serviceAccountAdmin. Choose this option when different teams, namespaces, or applications need different registry permissions under least privilege.
Cross-project access is required when the GKE cluster and the Artifact Registry repository live in different Google Cloud projects. The project boundary blocks automatic access, so the identity from the cluster project must be explicitly granted IAM permission in the registry project. The image data still flows from the Artifact Registry repository in one project to the kubelet on the GKE node in the other project, but only after IAM allows it.
A Kubernetes imagePullSecret is a namespace-scoped Secret that holds registry credentials for the kubelet to use during a pull. It is needed when automatic node credentials do not apply, such as pulls from another project without shared IAM grants or pulls from an external registry outside Google Cloud. The Pod references the imagePullSecret, and the kubelet on the node sends the stored credential to the registry with the pull request. Choose imagePullSecrets when access must be limited to specific Pods or namespaces, or when the registry cannot trust the node or workload IAM identity directly.
| Access method | Identity used | Best when |
|---|---|---|
| Node-level access | Node's Google Cloud service account | Cluster and registry share a project and all workloads share the same permission |
| Workload Identity Federation for GKE | Linked Kubernetes service account to IAM service account | Different workloads need different, least-privilege permissions to Google Cloud APIs |
| Kubernetes imagePullSecret | Stored credential referenced by the Pod | Registry is cross-project without IAM federation or is external to Google Cloud |
Exam tip: Use automatic node credentials for same-project pulls, but use a Kubernetes imagePullSecret or a federated IAM grant when the cluster and the Artifact Registry repository are in different projects.
IAM Role Assignment and Service Account Integration is how GKE proves its identity to Artifact Registry and pulls private container images. GKE nodes run as Compute Engine virtual machine instances, and each instance acts through a Google Cloud service account. When IAM grants that service account permission to read the repository, the nodes can download images automatically without storing long-lived keys in the cluster.
The Artifact Registry Reader role, named roles/artifactregistry.reader, is the IAM role that allows a principal to pull images from an Artifact Registry repository. The role grants read-only access to repository contents, which is sufficient for nodes that only need to download images to run Pods and Deployments. A custom IAM role can be used instead when it includes equivalent read permissions, while private Google Container Registry repositories use storage.objectViewer for the same purpose.
Binding this role to the node identity follows least privilege because nodes receive only pull access and cannot push, delete, or manage repositories. Granting broader roles to the node service account would give every workload on those nodes more access than needed to run containers. Choose Artifact Registry Reader when the requirement is to let GKE run private images from Artifact Registry in the same or a different project.
The GKE node service account is the Google Cloud service account attached to the cluster's node pool virtual machines. GKE clusters authenticate to Google Cloud APIs with this IAM service account, so image pulls from Artifact Registry flow from the node to the registry under this identity. In GKE on AWS, this identity is called the Node Pool Machine Service Agent, with a member name in the form service-CLUSTER_RESOURCE_PROJECT_NUMBER@gcp-sa-gkemulticloudnpmachine.iam.gserviceaccount.com.
This node account can be the Compute Engine default service account or a dedicated custom service account created for the cluster or node pool. The default account is shared and may already have broad access, while a custom account can be limited to only the projects and repositories the cluster needs. Choose a dedicated custom service account when multiple clusters or environments must be isolated from each other.
An IAM policy binding connects the node service account to the Artifact Registry Reader role in the project that hosts the repository. The binding is created with gcloud projects add-iam-policy-binding, which assigns the role to the service account member on the registry project. Once the binding exists, authorization flows from the node service account to Artifact Registry whenever the kubelet requests a private image.
The binding must be created in the project that owns the repository, even when the cluster lives in a different project. The command specifies the registry project ID, the full service account member name, and the role name. After this one-time grant, Pods and Deployments can reference the private image registry (opens in a new tab) path directly without an imagePullSecrets entry.
Exam tip: Use roles/artifactregistry.reader for Artifact Registry repositories and storage.objectViewer for Container Registry repositories; the two registries require different roles.
A Google Cloud service account is an IAM identity that belongs to a Google Cloud project and can be granted access to Google Cloud resources such as Artifact Registry. GKE on AWS version 1.28 and later uses this project-level identity to handle authentication and authorization for private image pulls automatically. This approach removes the older manual workflow that required managing service account keys inside the cluster:
Google Cloud service accounts differ from Kubernetes service accounts, which belong to a single cluster and are typically used only inside that cluster:
| Identity | Where it lives | What it can access |
|---|---|---|
| Google Cloud service account | Google Cloud project | Google Cloud resources through IAM, plus Kubernetes resources when granted |
| Kubernetes service account | Specific cluster namespace | Kubernetes API resources inside its cluster |
Because Google Cloud service accounts are more powerful, they should be used only where Google Cloud access is required and limited with IAM and Kubernetes role-based access control (RBAC).
LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG, and the repository must already exist before pushing or pulling.spec.containers[].image, while Deployments list the same image under spec.template.spec.containers.roles/artifactregistry.reader role grants GKE node service accounts read-only pull access to Artifact Registry repositories.The format is LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG, where LOCATION is the repository location such as us-west1, docker.pkg.dev identifies Docker-format repositories, and TAG is the version label such as staging or v1. The repository must already exist before pushing or pulling, and if no tag is specified Docker applies the default latest tag.
Use node-level access with the node's Google Cloud service account when the cluster and registry share a project and all workloads share the same permission. Use Workload Identity Federation for GKE when different workloads need different least-privilege permissions by linking a Kubernetes service account to a Google Cloud service account. Use a Kubernetes imagePullSecret when the registry is cross-project without IAM federation or is external to Google Cloud, or when access must be limited to specific Pods or namespaces.
The Artifact Registry Reader role, roles/artifactregistry.reader, grants read-only pull access to repository contents. The IAM policy binding must be created in the project that owns the Artifact Registry repository even when the cluster is in a different project, and after the grant Pods and Deployments can reference the private image path directly without an imagePullSecrets entry.
An operations team is deploying workloads to a Google Kubernetes Engine (GKE) cluster. The container images are stored in a private Artifact Registry repository in the same project.
To adhere to the principle of least privilege, the team configures the GKE cluster nodes to use a dedicated custom IAM service account rather than the Compute Engine default service account. The cluster nodes only need permission to download and run the container images.
Which IAM role should be assigned to the custom service account attached to the GKE nodes?
Artifact Registry Reader (roles/artifactregistry.reader)
Artifact Registry Administrator (roles/artifactregistry.admin)
Artifact Registry Writer (roles/artifactregistry.writer)
Storage Admin (roles/storage.admin)
Last updated