<p>I am pulling my hair out here. I deployed my template, deleted it, and then I go to deploy it again without any changes and am getting the following error:</p>
<p>The Deployment &quot;blog&quot; is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): <code>selector</code> does not match template <code>labels</code></p>
<p>My deployment yaml is below and as you can see the metadata and selector labels are both web, so I have no idea what the error is trying to tell me:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: blog
  labels:
    app: web
spec:
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
  replicas: 1
  template:
    spec:
      containers:
      - env:
        image: test_blog:latest
        imagePullPolicy: Always
        name: blog
        ports:
        - containerPort: 8080
</code></pre>

<p>You have two template block. I think thats the problem. Try this.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: blog
  labels:
    app: web
spec:
  selector:
    matchLabels:
      app: web
  replicas: 1
  template:
    metadata:
      labels:
         app: web
    spec:
      containers:
      - env:
        image: test_blog:latest
        imagePullPolicy: Always
        name: blog
        ports:
        - containerPort: 8080
</code></pre>
