> For the complete documentation index, see [llms.txt](https://jeffgthompsons-organization.gitbook.io/yellow-team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jeffgthompsons-organization.gitbook.io/yellow-team/training/cloud-guru/learn-kubernetes-by-doing/deploying-a-pod-to-a-node-with-a-label-in-kubernetes.md).

# Deploying a Pod to a Node with a Label in Kubernetes

## **Get All Node Labels**

**Run a command to get all labels for all cluster nodes**

```
kubectl get no --show-labels
```

<figure><img src="/files/cMfLCzHjboBwMfQ7EDpd" alt=""><figcaption></figcaption></figure>

We can also run this to show nodes by label

```
kubectl get no -l disk=ssd
```

## 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`**

**pod.yaml**

<pre><code>apiVersion: v1
kind: Pod
metadata:
    name: new-pod
spec:
   containers:
    - name: nginx
      image: nginx 
<strong>   nodeSelector:
</strong>      disk: ssd    
</code></pre>

**Apply the YAML to your Kubernetes cluster**

```
kubectl create -f pod.yaml
```

## Verify The pod is Running on the Correct Node

**Run a command that will show the pods and their associated nodes**

```
kubectl get po -o wide
```

<figure><img src="/files/qYhOJGCkpBNeSAE2XBp4" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jeffgthompsons-organization.gitbook.io/yellow-team/training/cloud-guru/learn-kubernetes-by-doing/deploying-a-pod-to-a-node-with-a-label-in-kubernetes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
