<p>After reading the official documentation on <a href="https://kubernetes.io/" rel="noreferrer">kubernetes.io</a>, I am still wondering what exactly is the difference between label and selector in Kubernetes?</p>
<p><strong>Editing:</strong> For example consider the following Kubernetes object, what is the difference between Labels and Selectors of the following yaml file.</p>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: label-demo
  labels:
    environment: production
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: App1
  template:
    metadata:
      labels:
        environment: production
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.7.9
</code></pre>

<p>Labels are key/value pairs that are attached to objects, such as pods. Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of objects.</p>

<p>Via a label selector, the client/user can identify a set of objects. The label selector is the core grouping primitive in Kubernetes.</p>

<p>In a nutshell label selectors depend on labels to select a group of resources such as pods. For example a deployment selects a group of pods by a label selector in the deployment spec.</p>
