看了kubernetes.io上的官方文档,我还是想知道 Kubernetes 中 label 和 selector 到底有什么区别?
编辑:例如考虑以下 Kubernetes 对象,以下 yaml 文件的 Labels 和 Selectors 有什么区别。
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
Run Code Online (Sandbox Code Playgroud)