Kubernetes
medium

Pregunta de Kubernetes #019e3a4f

Enunciado de la Pregunta
Kubernetes
#kubernetes
#service
#networking
#expose
Medio

What is the name of the Kubernetes resource used to expose an application?

A

Port

B

Service

Correcto
C

DNS

D

Deployment

Explicación Oficial / Explicaciones de la Comunidad

In Kubernetes, a Service is the resource used to expose an application running on a set of Pods as a network service. Services provide a stable IP address and DNS name, enabling load balancing and service discovery within the cluster.

How it Works

A Service defines a logical set of Pods and a policy to access them. It uses a selector to target Pods with specific labels. When a Service is created, Kubernetes assigns a virtual IP (ClusterIP) and a DNS name (e.g., my-service.namespace.svc.cluster.local). Traffic to the Service is load-balanced across the selected Pods.

Why the Correct Value is Right

  • Service is the correct Kubernetes resource for exposing applications. It abstracts the underlying Pod IPs and provides a consistent endpoint. Services can be of different types: ClusterIP (internal), NodePort (exposes on each node's IP), LoadBalancer (external load balancer), and ExternalName (maps to an external DNS name).

Why the Incorrect Values are Wrong

  • Port is not a Kubernetes resource; it is a field within a Service or Pod specification that defines the network port number. For example, a Service spec includes ports to map incoming traffic to target ports on Pods.
  • DNS is a system for name resolution, not a resource. Kubernetes has a built-in DNS service (kube-dns or CoreDNS) that automatically creates DNS records for Services, but DNS itself is not the resource that exposes an application.
  • Deployment is a resource that manages replica sets and provides declarative updates for Pods, but it does not expose them to network traffic. A Deployment ensures a desired number of Pods are running, but a Service is required to make those Pods accessible.

In summary, while Deployments manage Pods, Services expose them. Ports and DNS are components used in conjunction with Services, but the resource itself is the Service.