Deploying a Pod to a Node with a Label in Kubernetes

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you will need to create the pod YAML necessary to create a pod and assign that pod to a specific node with the label disk=ssd. First, find the node with that label, creat the YAML, then apply the YAML to the provided Kubernetes cluster. You will have completed this hands-on lab when you have verified that the pod is running successfully on the correct node.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Get All Node Labels
  • Run a command to get all labels for all cluster nodes
Create and Apply the Pod YAML
  • Create a file named pod.yaml and ensure that it has specified the node with the label disk=ssd
  • Apply the YAML to your Kubernetes cluster
Verify The pod is Running on the Correct Node
  • Run a command that will show the pods and their associated nodes

Additional Resources

You have been tasked with creating a pod named nginx, which needs to use the nginx image. This pod needs to run on a node that has solid state drives (SSD). Luckily, the nodes have already been labeled with the disk type. You must find the node with the label disk=ssd from within the provided Kubernetes cluster. Then, you will create the pod YAML which will force the pod to use the node with that label. Finally, you will apply the YAML to the Kubernetes cluster and verify that the pod is running on the correct node.

In order to complete this hands-on lab:

  • List the labels for all nodes in the cluster
  • Create the pod YAML that will choose to run on the node labeled disk=ssd
  • Apply the YAML to the Kubernetes cluster
  • Verify that the pod is running on the correct node

For more information on creating static pod, see: https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?