Let's see another use case. We used Deployments/ReplicaSets to replicate the Pods. It scales well and is easy to maintain and Kubernetes assigns a DNS to the Pod using the Pod's IP address, such as <Pod IP address>.<namespace>.pod.cluster.local.
The following example demonstrates how the Pod DNS will be assigned:
$ kubectl run apache2 --image=httpd --replicas=3deployment "apache2" created//one of Pod has an IP address as 10.52.1.8$ kubectl get pods -o wideNAME READY STATUS RESTARTS AGE IP NODEapache2-55c684c66b-7m5zq 1/1 Running 0 5s 10.52.1.8 gke-chap7-default-pool-64212da9-z96qapache2-55c684c66b-cjkcz 1/1 Running 0 1m 10.52.0.7 gke-chap7-default-pool-64212da9-8gzmapache2-55c684c66b-v78tq 1/1 Running 0 1m 10.52.2.5 ...