Google Kubernetes Engine (GKE) | JPEG Image-Resizing API | IP Address Retrieval

JPEG Image-Resizing API IP Address Retrieval

Question

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?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

The correct answer is option B: Define a GKE Service. Clients should use the service name in the URL to connect to the service.

When running applications on GKE, a Kubernetes Service is a resource that abstracts away the underlying pods and provides a stable IP address and DNS name for clients to use when accessing the application. A Service allows you to expose your application to the network, enabling communication between different parts of the application or between other applications in the same cluster.

In this scenario, the goal is to allow clients within the same GKE cluster to access the JPEG image-resizing API and retrieve its IP address. Therefore, the solution is to define a GKE Service for the API.

Option A suggests using the A record in Cloud DNS to find the service's cluster IP address. This is not recommended since it relies on DNS resolution and can result in added latency and potential DNS issues.

Option C suggests defining a GKE Endpoint and having clients get the endpoint name from the appropriate environment variable in the client container. This option requires more configuration on the client-side and can introduce errors if the environment variable is not set correctly.

Option D suggests having clients get the endpoint name from Cloud DNS. As mentioned earlier, relying on DNS resolution can lead to added latency and potential DNS issues.

Therefore, the best approach is to define a GKE Service for the JPEG image-resizing API and have clients use the service name in the URL to connect to the service. This way, clients can retrieve the IP address of the service in a simple and straightforward manner.