The .spec.selector field defines how the Deployment finds which Pods to manage. But we also defines labels inside template then what is the extra things we are getting with .spec.selectors field because Deployment can find the Pods to be managed with the label defined in template also ?
In the below code how can the pod with "label occloud.oracle.com/open-network-policy: allow" is managed by deployment as it is not described in spec.selectors
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cheeseshop
spec:
replicas: 1
progressDeadlineSeconds: 180
selector:
matchLabels:
app.kubernetes.io/name: tutorial
app.kubernetes.io/component: cheeseshop
template:
metadata:
labels:
app.kubernetes.io/name: tutorial
app.kubernetes.io/component: cheeseshop
occloud.oracle.com/open-network-policy: allow
name: cheeseshop