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

spec:

containers:

- name: nginx

image: nginx

imagePullPolicy: IfNotPresent

nodeSelector:

kubernetes.io/image-name: nginx

The resulting pod-nginx.yaml is shown in a vi editor in Figure 9-21.

Figure 9-21. The pod definition file pod-nginx.yaml

Create a pod using the definition file:

kubectl create -f pod-nginx.yaml

Similarly, create another pod definition file pod-helloworld.yaml. Copy the following listing into

pod-helloworld.yaml:

apiVersion: v1

kind: Pod

metadata:

name: hello-world

labels:

env: test

spec:

containers:

- name: hello-world

image: hello-world

imagePullPolicy: IfNotPresent

nodeSelector:

kubernetes.io/image-name: hello-world

215

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

Saved successfully!

Ooh no, something went wrong!