---
description: Describe about Node Selector
---

# Node Selector

Node Selector is a property that allows you to specify the node when creating the Pod or any other resource. The value of this property is derived from the label of the Node.\
\
**Example:**&#x20;

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2FEutalBCJhawOLvB9VCF7%2Ffile.excalidraw.svg?alt=media&#x26;token=516ddbf6-3526-45b1-b333-9168eae570bf" alt="" class="gitbook-drawing">

We aim to deploy the Pod on the Node with the highest available resources.

1. We add the label to `Node A` by using this command: `kubectl label node <node_name> <label_key>=<label_value>`
2. Add the `Node Selector` property in `Pod` template

```yaml
# Pod Template
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels: 
    name: nginx
spec: 
  containers:
  - name: nginx
    image: nginx 
    ports:
      - containerPort: 8080
  nodeSelector: 
    <label_key>: <label_value>
          
```

**Disadvantage of this strategy:**

* If we label Node A as "Large" and Node B as "Medium," our requirement is to deploy the Pod on a Node with either "Large" or "Medium" resources. However, the current configuration does not allow for this preference.
