Why labels are mentioned three times in a single deployment

后端 未结 3 1191
清歌不尽
清歌不尽 2021-01-12 13:59

I\'ve gone over the following docomentation page: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

The example deployment yaml is as follows:

3条回答
  •  情深已故
    2021-01-12 14:47

    .metadata.labels is for labeling the deployment object itself, you don't necessarily need it, but like other answers said, it helps you organize objects.

    .spec.selector tells the deployment(under the hood it is the ReplicaSet object) how to find the pods to manage. For your example, it will manage pods with label app: nginx.

    But how do you tell the ReplicaSet controller to create pods with that label in the first place? You define that in the pod template, .spec.template.metadata.labels.

提交回复
热议问题