O'Reilly logo

Kubernetes Cookbook, 2nd Edition by Ke-Jou Carol Hsu, Hui-Chuan Chloe Lee, Hideto Saito

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running a stateful Pod

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required