19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 ■ Scheduling Pods on Nodes

Next, we shall demonstrate that if multiple pods have matching labels, one of the nodes is used. Label

the third node with the same label as one of the other nodes:

kubectl label nodes ip-10-0-0-153.ec2.internal kubernetes.io/image-name=hello-world

The third node is also labeled, as shown in Figure 9-25.

Figure 9-25. Labeling a third node

Listing the node labels should display two nodes with the common label kubernetes.io/imagename=hello-world,

as shown in Figure 9-26.

Figure 9-26. Two nodes with the same label

Delete the pod hello-world with kubectl, as next we shall create the pod again to find which node is

the pod scheduled on, given two nodes with the same label as in the nodeSelector field. Create the helloworld

pod again using the same definition file. List the pod, and it should be shown on one of the two nodes

that have the label kubernetes.io/image-name=hello-world, which are ip-10-0-0-152.ec2.internal

and ip-10-0-0-153.ec2.internal. The pod is scheduled on the first node it finds with the matching label,

which is ip-10-0-0-152.ec2.internal as shown in Figure 9-27.

217

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!