# 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="<https://2706222677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mg-RBIbw2wF_IDwm1S7%2F-Mg-xhSWmF9AfTBl7bUw%2F-Mg0O3N9a7557P3j6Jdy%2Fhelloworld-pod-with-labels.yml?alt=media&token=989261d2-a386-42cf-8a30-2f5347dd3fa3>" %}

```
$ 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 %}
