Prepare and test your skills

Prepare and test your skills

Configuring networking through Kubernetes Services means giving clients a stable address for an application even though the Pods behind it keep changing. A Service hides Pod replacements, moves, and rescheduling so internal callers and internet users always have one consistent endpoint to use.
A Kubernetes Service is a networking abstraction placed on top of Pods that provides a stable IP address and discovery mechanism. Pods do not have stable addresses because no one controls which node a Pod runs on, and Pods can be created, moved, or replaced at any time. In Google Kubernetes Engine (GKE) (opens in a new tab), nodes are Compute Engine virtual machines grouped into a cluster, while the Google-managed control plane runs components such as the Kubernetes API server. The Service (opens in a new tab) stays fixed while the Pods and nodes underneath it change, and different Service types such as ClusterIP, NodePort, and LoadBalancer support internal discovery and external routing.
Exposing an application through a Service in GKE connects three elements that carry traffic from clients to Pods. The frontend listens for traffic, routing rules decide where that traffic should go, and backends receive the traffic.
Traffic flows from clients to the frontend, then through the routing and load balancing rules, and then to the backends. GKE updates the backends dynamically as GKE endpoints come up and down, so the Service keeps working even when individual Pods change.
A left-to-right process flow showing client traffic moving through a load balancer frontend and routing rules to backend Pods behind a stable Service IP.
Internal and external traffic in GKE are separated by where the load balancer frontend listens and which clients can reach it. An external Application Load Balancer listens on the public internet through hundreds of Google points of presence, so traffic is terminated at the edge close to clients before it is balanced to backends in a Google data center. An internal Application Load Balancer listens within the scope of your Virtual Private Cloud (VPC) network, so communication stays private inside that network. The choice of frontend therefore defines the trust and network boundary for the Service.
Exam tip: Choose an external frontend when clients are on the public internet, and an internal frontend when traffic must stay inside your VPC network.
GKE load balancing is automated by the GKE Ingress controller and the GKE Service controller, which deploy and manage load balancers for users. An administrator applies a declarative manifest to the GKE cluster, and the controllers watch for networking resources such as Ingress objects. The controllers then create the load balancer plus supporting resources such as IP addressing and firewall rules, and they continue to manage the load balancer and backends as conditions change. This dependency means developers use a Kubernetes interface while GKE controls the lifecycle of the underlying Google load-balancing infrastructure.
Implementing stateful applications and persistent storage means saving data that must live longer than any single Pod. Stateful workloads in GKE use durable volumes and stable Pod identities so data survives restarts, rescheduling, and scaling.
Stateless and stateful applications in **Google Kubernetes Engine (GKE) (opens in a new tab) differ by whether they must save data beyond the lifetime of their Pod. Stateless applications do not store data or application state to the cluster or to persistent storage, so any replica can be replaced without recovery. Stateful applications must save data that exists beyond the Pod lifetime, because files inside a container are ephemeral and are lost when a container restarts.
| Workload type | Keeps data after Pod restarts | Storage approach |
|---|---|---|
| Stateless application | No, no data or state is saved to the cluster | No persistent storage, deployed through the Kubernetes API |
| Stateful application | Yes, data must exist beyond the lifetime of the Pod | PersistentVolume backed by a Compute Engine disk, or an external or managed database |
A Pod in GKE acts as an app-specific logical host for one or more containers running on a node. Containers in the same Pod can share a set of storage volumes, which lets data survive container restarts and be shared among containers in that Pod.
PersistentVolume (PV) resources manage durable storage in a GKE cluster. A PersistentVolume in GKE is typically backed by a Compute Engine persistent disk, although other solutions such as NFS through Filestore can also be used. PersistentVolume resources are cluster resources that exist independently of Pods, so the disk and the data they represent continue to exist as the cluster changes and as Pods are deleted and recreated.
The PersistentVolume lifecycle is managed by Kubernetes. A PersistentVolume can be dynamically provisioned so backing storage does not have to be created and deleted manually, or it can be explicitly created by a cluster administrator. One type of provisioning uses the GCE PD StorageClass, which connects Compute Engine persistent disks to containers so data files are not deleted when Pods restart.
A PersistentVolumeClaim (opens in a new tab) (PVC) is a request for and claim to a PersistentVolume resource. The PersistentVolumeClaim object requests a specific size, access mode, and StorageClass for the PersistentVolume that should back it. Kubernetes then binds that claim to a matching PersistentVolume, either by dynamically provisioning a new disk or by using an administrator-created volume.
StorageClasses describe the type of storage to provide, and volumes implement the actual storage attached to Pods. This separation lets developers request storage by size and class without managing disks directly, while storage specialists create and allocate the underlying disks and configure protection and access. In GKE, this orchestration connects the claim from the workload to durable Compute Engine disk storage that persists independently of any single Pod.
Exam tip: A PersistentVolume continues to exist after its Pod is deleted, while a PersistentVolumeClaim is the request that specifies size, access mode, and StorageClass.
StatefulSets are the workload controller for state-dependent workloads that need data persistence and stable identity for each Pod. Deployments are suited to stateless applications where any Pod replica is interchangeable and no data must survive restarts. StatefulSets are suited to stateful applications such as databases where each replica needs its own persistent storage and a stable network identity that follows it through rescheduling, updates, and scaling.
Choose a Deployment when Pods do not store data to the cluster. Choose a StatefulSet when the application must save data beyond the lifetime of its Pod and each Pod must keep its own data and identity.
Storage for a simple stateful application in GKE uses a PersistentVolume backed by Compute Engine disks. The volume is mounted into the Pod so the application can read and write files that remain after container restarts. This approach keeps storage tied to the cluster lifecycle and is useful for workloads that need file storage directly attached to Pods.
When stateful data must persist in a database rather than in cluster-attached storage, GKE offers two paths. A fully managed database such as Cloud SQL or Spanner provides reduced operational overhead and is optimized for Google Cloud infrastructure. A database run as a Kubernetes application, such as MySQL on a GKE cluster, keeps the database inside Kubernetes but requires more effort to maintain and operate than a managed service.
Managing stateless workloads and Pod lifecycles means running replaceable replicas that do not save data to the cluster. Deployments keep the right number of identical Pods running and move them toward a new desired state during scaling or updates.
Pods are the basic unit that runs containers on nodes in a GKE cluster. A Pod holds one or more containers that are scheduled together onto the same node, and Pods are temporary by nature because they can be created, deleted, and replaced during scaling or updates. Data that must exist beyond the lifetime of a Pod cannot stay inside the Pod and requires separate storage. This temporary lifetime is why stateless design works well, since a lost Pod can be replaced by an identical Pod without data recovery.
Stateless applications are applications that do not store data or application state to the cluster or to persistent storage. Data and application state stay with the client instead, which makes stateless applications more scalable because replicas do not depend on local data. A frontend application is a common example where multiple replicas increase availability, scale down when demand is low, and need no unique identities. In **Google Kubernetes Engine (GKE) (opens in a new tab), you package an app into containers and deploy sets of containers as Pods onto nodes, which are Compute Engine virtual machines grouped into a cluster.
A Deployment (opens in a new tab) is the Kubernetes controller that deploys stateless applications as uniform, non-unique Pods. The Deployment manages the desired state of the application, including how many Pods should run, what version of the container image should run, and what labels the Pods should carry. Container images for the Deployment are stored in an image registry such as Artifact Registry, and a simple Deployment can create three replicated Pods with the same label running the same image. You interact with those workloads through the Kubernetes API while Google Cloud manages the control plane that runs the API server, and changing the replica count or image version in the Deployment Pod specification causes GKE to move the running Pods toward the new desired state.
Exam tip: Use a Deployment for stateless apps with identical, replaceable Pods, while stateful apps that save data use a StatefulSet with unique Pods and PersistentVolume storage backed by Compute Engine disks.
A Deployment in Google Kubernetes Engine (GKE) manages stateless applications as uniform, interchangeable Pods that do not save data to the cluster, while a StatefulSet manages stateful applications that need persistent storage and a stable network identity for each Pod. Choose a Deployment when Pods do not store data to the cluster and choose a StatefulSet when each Pod must keep its own data and identity through rescheduling, updates, and scaling.
A PersistentVolume (PV) in Google Kubernetes Engine (GKE) is durable cluster storage that exists independently of Pods and is typically backed by a Compute Engine persistent disk, while a PersistentVolumeClaim (PVC) is a request for and claim to a PersistentVolume that specifies size, access mode, and StorageClass. Kubernetes binds the claim to a matching volume either by dynamically provisioning a new disk or by using an administrator-created volume.
A Kubernetes Service provides a stable IP address and discovery mechanism that stays fixed while Pods are created, moved, or replaced across nodes. Pods do not have stable addresses because no one controls which node a Pod runs on, and Pods can be created, moved, or replaced at any time.
An external Application Load Balancer frontend listens on the public internet and terminates traffic at the edge close to clients before balancing it to backends, while an internal frontend listens within the scope of your Virtual Private Cloud (VPC) network so communication stays private inside that network. Choose an external frontend when clients are on the public internet and an internal frontend when traffic must stay inside your VPC network.
Your company is deploying a distributed, replicated database workload onto a Google Kubernetes Engine (GKE) cluster.
The database architecture has the following operational requirements:
db-0, db-1) that persists across restarts and rescheduling.Which Kubernetes workload resource and configuration should you deploy?
Deploy a Deployment with a shared PersistentVolumeClaim defined in the Pod template and a ClusterIP Service
Deploy a DaemonSet utilizing emptyDir volumes and exposed via a NodePort Service
Deploy a Job controller with dynamic PersistentVolume binding and an Ingress resource
Deploy a StatefulSet configured with volumeClaimTemplates and coupled with a headless Service
Last updated