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?
A.
Define a GKE Service. Clients should use the name of the A record in Cloud DNS to find the service's cluster IP address.
B.
Define a GKE Service. Clients should use the service name in the URL to connect to the service.
C.
Define a GKE Endpoint. Clients should get the endpoint name from the appropriate environment variable in the client container.
D.
Define a GKE Endpoint. Clients should get the endpoint name from Cloud DNS.
It's B - Clients are in the cluster and therefore can use service dns names.
https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
"Every Service defined in the cluster (including the DNS server itself) is assigned a DNS name. By default, a client Pod's DNS search list includes the Pod's own namespace and the cluster's default domain."
B. This is the standard Kubernetes service discovery mechanism. When you define a Service in Kubernetes, it creates a DNS entry in the internal cluster DNS. Any pod in the cluster can then reach the service using the service name as a DNS name (e.g., http://service-name). This is the most straightforward and Kubernetes-native way to enable service discovery within a cluster.
A.
GKE endpoint is external facing, Opt C and D are out. Also exposing to endpoint won't expose all containers in the GKE cluster - if one service exposes to 4000 nodes with containers then does this mean the GKE would need to update 4000 times? This just doesn't make sense. Opt B use service name, in other words, CNAME, so it still has to go through Cloud DNS. Hence the opt A shall be correct.
both A and B are valid
Option A, DNS A record maps service FQDN to IP address, fqdn like service-name.default.svc.cluster.local
B is more easier, just use http://service-name
C answer is suggesting to define endpoint in the service and others can use that endpoint (reading its name from a variable) to ask the service what IP it has, that why I think C is correct.
https://cloud.google.com/kubernetes-engine/docs/concepts/service-discovery
"In Kubernetes, service discovery is implemented with automatically generated service names that map to the Service's IP address. Service names follow a standard specification: as follows: my-svc.my-namespace.svc.cluster-domain.example. Pods can also access external services through their names, such as example.com. "
B is collect.
If client and server are in same namespace, C is collect.But in this case, no condition of namespace. So client pod must be use server service name.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
accuracy23
Highly Voted 3 years, 5 months agosantoshchauhan
Most Recent 7 months, 3 weeks agoRaja2112
1 year ago__rajan__
1 year, 1 month agomaxdanny
1 year, 2 months agozanhsieh
1 year, 4 months agogc_exam2022
1 year, 5 months agocloser89
1 year, 5 months agotelp
1 year, 9 months agoMark123321
1 year, 10 months agoMark123321
1 year, 10 months agoajipeggy
1 year, 11 months agotomato123
2 years, 2 months agokinoko1330
2 years, 2 months agoalex8081
2 years, 2 months agojdx000
2 years, 3 months agonazonazonazo
2 years, 8 months agozaxxon
2 years, 9 months agoralf_cc
3 years, 4 months ago