# 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 %}


---

# Agent Instructions: 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://amdocs-1.gitbook.io/kubernetes-handbook/labels-namespaces-and-selectors/labels.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.
