title: Why is a Kubernetes Deployment YAML file so repetitive?
body: <p>The first and most minimal <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="noreferrer">example of a Deployment in the Kubernetes documentation</a> has the <code>app: nginx</code> line that repeats itself three times. I understand it's a tag, but I haven't found anything that explains why this needs to be specified for all of:</p>
  
  <ol>
  <li><code>metadata.labels</code>,</li>
  <li><code>spec.selector.matchLabels</code>, and</li>
  <li><code>spec.template.metadata.labels</code></li>
  </ol>
  
  <p>The example deployment file:</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: nginx-deployment
    labels:
      app: nginx
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: nginx
    template:
      metadata:
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: nginx:1.7.9
          ports:
          - containerPort: 80
  </code></pre>