Google ACE Deploying and Implementing a Cloud Solution Practice Question
After deploying a Kubernetes Deployment named 'web-app', a developer wants to expose it externally on a static IP address. Which kubectl command should they use?
⚠ Common exam trap
Test-takers frequently confuse Service types — candidates pick NodePort thinking it provides external access, but only LoadBalancer (or Ingress backed by one) yields a static external IP on GKE.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
kubectl expose deployment web-app --type=LoadBalancer --port=80 --target-port=8080
The `kubectl expose deployment` command creates a Service from an existing Deployment, and `--type=LoadBalancer` provisions an external load balancer with a stable, externally reachable IP (on GKE, a Google Cloud network load balancer). The `--port=80` sets the Service port and `--target-port=8080` maps traffic to the container's listening port, which is exactly what's needed to expose the app externally on a static IP.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl create service clusterip web-app --tcp=80:8080
Why it's wrong here
The `kubectl create service clusterip` command creates a ClusterIP Service, which assigns the Deployment a stable virtual IP reachable only from inside the cluster—it does not create any external IP, ingress, or load balancer. While the port mapping 80:8080 is valid, this Service type is designed for internal east-west traffic (e.g., other Pods), not for internet-facing access. For a web application that needs a public static IP, a LoadBalancer or explicit Ingress is required, so this option fails to expose the app externally.
- ✗
gcloud compute forwarding-rules create web-app --port=80
Why it's wrong here
`gcloud compute forwarding-rules create` targets classic or external load balancing configurations for Compute Engine instances and instance groups, not Kubernetes-native resources. GKE Services are reconciled by the Kubernetes controller and interact with the cloud provider's load balancing via a Service of type LoadBalancer, so manually creating a forwarding rule does not attach it to the Deployment or open a path to the container ports. Moreover, a forwarding rule requires backend services and health checks; issuing only this command would create an unusable, orphaned rule, and it is not part of the kubectl workflow that GKE expects.
- ✓
kubectl expose deployment web-app --type=LoadBalancer --port=80 --target-port=8080
Why this is correct
This is the correct approach because `kubectl expose deployment` with `--type=LoadBalancer` automatically creates a Kubernetes Service that instructs GKE to provision a cloud load balancer and allocate an external IP address. The `--port=80` specifies the Service port, while `--target-port=8080` directs traffic to the container's actual listening port on the Pod, matching the Deployment's container specification. If a reserved static IP is needed, you would reserve it in advance and add the `--load-balancer-ip` flag or annotate the Service; GKE then assigns that address to the load balancer.
- ✗
kubectl expose deployment web-app --type=NodePort --port=80
Why it's wrong here
`kubectl expose deployment web-app --type=NodePort` creates a Service that exposes the app on a random high-port (default 30000-32767) on every node's IP, rather than providing a managed external load balancer or a static IP. Because the command omits `--target-port`, the Service defaults the target port to the value of `--port` (80), but the container listens on 8080, causing connections to fail. Even if the target port were corrected, NodePort would still expose the app through a volatile node IP/port, which is not a production-grade external endpoint for GKE.
Go deeper
Related to this question
Learn chapter
GCP Service Accounts and Workload Identity
Key term
Container
A container is a lightweight, standalone software package that includes everything needed to run an application, such as code, runtime, system tools, and libraries.
Key term
Google Cloud
Google Cloud is a suite of cloud computing services offered by Google that provides infrastructure, platform, and software solutions over the internet.
About these practice questions
One of 775 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Google Cloud exam blueprint
This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.