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

marco.cirilli
from marco.cirilli More from this publisher
19.06.2021 Views

Chapter 9 ■ Scheduling Pods on NodesFigure 9-59. Setting all the kubernetes.io/image-name key values to non existing valuesDelete the pod with-labels and create the pod again. The pod is still scheduled even though none ofthe nodes have matching labels, as shown in Figure 9-60. By comparison, when we used the node affinityrequiredDuringSchedulingIgnoredDuringExecution with none of the nodes having matching labels, thepods were placed in Pending status until a matching label was added. Now the pod is scheduled because thepreferredDuringSchedulingIgnoredDuringExecution setting is not binding and is only a hint.Figure 9-60. Pods are scheduled even though no nodes with matching labels are foundThe nodeSelector field if specified with node affinity preferredDuringSchedulingIgnoredDuringExecutionis still guaranteed. Add the nodeSelector field with the label kubernetes.io/image-name: nginx as shown inFigure 9-61. All the other matching expressions are set to kubernetes.io/image-name: hello-world.235

Chapter 9 ■ Scheduling Pods on NodesFigure 9-61. Setting nodeSelector in addiiton to node affinitypreferredDuringSchedulingIgnoredDuringExecutionDelete and create the with-labels pod again. The pod is scheduled on the node with kubernetes.io/image-name: nginx label because the nodeSelector expression is kubernetes.io/image-name: nginx asshown in Figure 9-62.Figure 9-62. The pod is scheduled on the node with label matching the nodeSelector expressionSummaryIn this chapter we first discussed the default scheduling policy used by Kubernetes. Then we used the defaultscheduler and also the node selector to schedule pods on nodes. We also discussed scheduling pods usingnode affinity. In the next chapter we shall discuss configuring compute resources.236

Chapter 9 ■ Scheduling Pods on Nodes

Figure 9-59. Setting all the kubernetes.io/image-name key values to non existing values

Delete the pod with-labels and create the pod again. The pod is still scheduled even though none of

the nodes have matching labels, as shown in Figure 9-60. By comparison, when we used the node affinity

requiredDuringSchedulingIgnoredDuringExecution with none of the nodes having matching labels, the

pods were placed in Pending status until a matching label was added. Now the pod is scheduled because the

preferredDuringSchedulingIgnoredDuringExecution setting is not binding and is only a hint.

Figure 9-60. Pods are scheduled even though no nodes with matching labels are found

The nodeSelector field if specified with node affinity preferredDuringSchedulingIgnoredDuringExecution

is still guaranteed. Add the nodeSelector field with the label kubernetes.io/image-name: nginx as shown in

Figure 9-61. All the other matching expressions are set to kubernetes.io/image-name: hello-world.

235

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

Saved successfully!

Ooh no, something went wrong!