19.06.2021 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9 ■ Scheduling Pods on Nodes

Figure 9-19. Labeling nodes

List the nodes, including the labels, using the –show-labels command argument to the kubectl get

nodes command. The labels added are listed in addition to the default labels, as shown in Figure 9-20.

Figure 9-20. Listing nodes including labels

When using labels to match pods with nodes, one of the following results:

1. The pod is scheduled on the labeled node.

2. The pod is scheduled on an unlabeled node if a node affinity is specified.

3. The pod is not scheduled.

We shall discuss each of these in the following sections using the labeled and unlabeled nodes from this

section.

Scheduling Pods with a Node Selector

The nodeSelector field in a pod’s specification may be used to explicitly select a node for a pod. To assign a

pod to a label, create a pod definition file pod-nginx.yaml. Copy the following code to the definition file:

apiVersion: v1

kind: Pod

metadata:

name: nginx

labels:

env: test

214

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

Saved successfully!

Ooh no, something went wrong!