Giriş
Açıklaması şöyleHeadless ServiceYou can set up a DNS service for your Kubernetes cluster using an add-on.We all know how DNS works in the case of the internet. Every website has a unique address a.k.a domain (for e.g. www.amazon.com). A similar approach is applied in the case of service discovery in Kubernetes. DNS server watches the Kubernetes for new services and creates a set of DNS records for each one. If DNS has been enabled throughout your cluster then all Pods should automatically be able to resolve services by their DNS name.For instance, in our case, the DNS service and control plane (Kubernetes control panel) acting together create a DNS record of shoppingcart-service.dev-ns . Pods in the dev-ns the namespace should be able to find the service by doing a name lookup for shoppingcart-serviceKubernetes provides the concept of namespaces to segregate different concerns. For instances, you can have different namespaces for dev, test and prodenvironments.
Açıklaması şöyle
ÖrnekLuckily, Kubernetes allows clients to discover pod IPs through DNS lookups. Usually, when you perform a DNS lookup for a service, the DNS server returns a single IP — the service’s cluster IP. But if you tell Kubernetes you don’t need a cluster IP for your service (you do this by setting the clusterIP field to None in the service specification ), the DNS server will return the pod IPs instead of the single service IP. Instead of returning a single DNS A record, the DNS server will return multiple A records for the service, each pointing to the IP of an individual pod backing the service at that moment. Clients can therefore do a simple DNS A record lookup and get the IPs of all the pods that are part of the service. The client can then use that information to connect to one, many, or all of them.Setting the clusterIP field in a service spec to None makes the service headless, as Kubernetes won’t assign it a cluster IP through which clients could connect to the pods backing it.
Şöyle yaparız
apiVersion: v1kind: Servicemetadata:name: grpc-server-servicespec:clusterIP: Noneselector:app: grpc-serverports:- port: 80targetPort: 8001
Hiç yorum yok:
Yorum Gönder