# 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="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FKjiB21zbWZ0QylQAb9a0%2Fimage.png?alt=media&#x26;token=5932f7b4-3910-468e-89a5-36c9d6d7ab81" 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="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FLuJnV8RNFyr5gUdYeaiC%2Fimage.png?alt=media&#x26;token=dcf4ceba-23c9-4818-9f91-8a74aecaedb8" alt=""><figcaption></figcaption></figure>
