GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 11 of 35
You are developing a JPEG image-resizing API hosted on Google Kubernetes Engine (GKE). Callers of the service will exist within the same GKE cluster. You want clients to be able to get the IP address of the service. What should you do?
Full set: 265 questionsThe standard and recommended method for service discovery within a Google Kubernetes Engine (GKE) cluster is to use a Kubernetes Service object. When a Service is created, GKE's internal DNS service (CoreDNS) automatically creates a DNS A record (e.g., my-service.my-namespace.svc.cluster.local). Client applications running in pods within the same cluster can then use the simple service name (e.g., http://image-resizing-api/) in their connection strings. The cluster's DNS resolver, configured by default in each pod, resolves this name to the stable internal IP address (ClusterIP) of the Service. This approach decouples the client from the service's IP address, providing a stable endpoint.
A. This is incorrect because in-cluster service discovery uses the cluster's internal DNS service (CoreDNS), not Google Cloud DNS, which is for public or VPC-scoped DNS resolution.
C. You define a Service, which then automatically creates and manages an Endpoint object. Manually defining an Endpoint is not standard practice. Also, DNS is the recommended discovery method over legacy environment variables.
D. This is incorrect because you should define a Service, not an Endpoint, and use the cluster's internal DNS for discovery, not Google Cloud DNS.
1. Google Cloud Documentation, "Exposing applications using services": "When you create a Service of type ClusterIP, GKE creates a stable IP address that is accessible from within the cluster's nodes... GKE also assigns the Service a DNS name... Applications in the cluster can use this stable DNS name to call the Service." This directly supports using a Service and its DNS name for in-cluster communication.
Source: Google Cloud Documentation, Google Kubernetes Engine, Concepts, "Exposing applications using services".
2. Official Kubernetes Documentation, "Service": "Kubernetes Pods are created and destroyed to match the state of your cluster. Pods are nonpermanent resources... A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them... For cluster-internal communication, Kubernetes offers a simple DNS resolution for Services."
Source: Kubernetes.io, Documentation, Concepts, Services, Load Balancing, and Networking, "Service".
3. Official Kubernetes Documentation, "DNS for Services and Pods": "Kubernetes creates DNS records for Services and Pods... A client Pod can then connect to the service using just its name... For a Service named my-service in a Kubernetes Namespace my-ns, the control plane and the DNS Service acting together create a DNS record for my-service.my-ns."
Source: Kubernetes.io, Documentation, Concepts, Services, Load Balancing, and Networking, "DNS for Services and Pods".
4. Official Kubernetes Documentation, "Service - Environment variables": This section describes the environment variable injection mechanism for service discovery but notes its primary limitation: "This does mean you have to create the Service before you create any client Pods that you want to use that Service." It is considered a legacy alternative to the more flexible DNS-based discovery.
Source: Kubernetes.io, Documentation, Concepts, Services, Load Balancing, and Networking, "Service", Section: "Environment variables".
Keep practicing
Take the free GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice questions
- Question 1You have an application controlled by a managed instance group. When you deploy a new ver…
- Question 2Your service adds text to images that it reads from Cloud Storage. During busy times of t…
- Question 3You have been tasked with planning the migration of your company’s application from on-pr…
- Question 4You plan to make a simple HTML application available on the internet. This site keeps inf…
- Question 5HipLocal's APIs are showing occasional failures, but they cannot find a pattern. They wan…
- Question 6Your company has created an application that uploads a report to a Cloud Storage bucket. …
