<p>I have the following deployment.yaml file in Kuberentes:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: basic-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: basic
    spec:
      containers:
      - name: basic
        image: nginx
        volumeMounts:
        - name: config-volume
          mountPath: /etc/nginx/conf.d
      volumes:
      - name: config-volume
        configMap:
          name: basic-config
</code></pre>

<p>I am not sure how I can fix the following error when I run <code>kubectl create -f basic-deployment.yaml</code>:</p>
<p><strong>The Deployment &quot;basic-deployment&quot; is invalid: spec.template.metadata.labels: Invalid value: map[string]string{&quot;app&quot;:&quot;basic&quot;}: <code>selector</code> does not match template <code>labels</code></strong></p>

coderWorld
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: basic-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: basic
  template:
    metadata:
      labels:
        app: basic
    spec:
      containers:
      - name: basic
        image: nginx
        volumeMounts:
        - name: config-volume
          mountPath: /etc/nginx/conf.d
      volumes:
      - name: config-volume
        configMap:
          name: basic-config
</code></pre>
<p>Basically, the selector match label in your deployment spec needs to match a label in your template. In your case, you have <code>app: nginx</code> as a matching label for the selector and you have <code>app: basic</code> in your template, so no match.</p>
<p>You would have to have something either one <code>app: nginx</code> or <code>app: basic</code> on both so that there is a match.</p>
