> For the complete documentation index, see [llms.txt](https://amdocs-1.gitbook.io/kubernetes-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://amdocs-1.gitbook.io/kubernetes-handbook/labels-namespaces-and-selectors/labels.md).

# Labels

* Labels are key value pairs attached to pods, deployments, services
* For users to identify attributes of object
* Unique per object

## Labels with Selectors

Labels with selectors let you identify specific set of objects

* **Equality based selector**: labels equal/unequal
* **Set based selector**: labels in/not in/exists
* Used with **kubectl**

{% file src="/files/-Mg0O3N9a7557P3j6Jdy" %}

```
$ kubectl create -f helloworld-pod-with-labels.yml
```

```
$ kubectl get pods
```

```
$ kubectl get pods - -show-labels
```

## Assigning labels to running Pods

```
$ kubectl label po/helloworld app=myApp - -overwrite
```

{% hint style="info" %}
Overwrites the app name
{% endhint %}

```
$ kubectl label po/helloworld author=chandrikadeb7 --overwrite
```

{% hint style="info" %}
Overwrites author name
{% endhint %}

```
$ kubectl label po/helloworld author- 
```

{% hint style="info" %}
Deletes the label author
{% endhint %}
