Cloud and Container Basics
In Kubernetes, a Pod gets a different IP address every time it is recreated. Which of the following resources lets other applications connect, through a name and address that do not change, to several Pods selected by labels, with the load spread across them?
- AConfigMap
- BService
- CPersistentVolume
Show answer and explanation
Answer: B. Service
A Service gives the set of Pods that match its label selector a virtual IP address and a DNS name that stay the same within the cluster, and distributes incoming traffic to those Pods. Even when Pods are replaced, clients only need to connect using the Service's name, so they do not need to know the Pods' addresses. To expose it outside the cluster, set the type to NodePort or LoadBalancer, or use an Ingress. A ConfigMap is a resource for configuration values, and a PersistentVolume is one for persistent storage.
- A. A ConfigMap is a resource for passing configuration values to Pods separately from the image.
- B. Correct. A Service distributes traffic to several Pods through a stable name and address.
- C. A PersistentVolume is a resource representing storage that remains even when Pods are recreated.