After reading the official documentation on kubernetes.io, I am still wondering what exactly is the difference between label and selector in Kubernetes?
Editing: For example consider the following Kubernetes object, what is the difference between Labels and Selectors of the following yaml file.
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