<p>I'm new in Kubernetes and I was tring to deploy a nodejs service to kubernetes. For that I created a docker image and upload it to dockerhub and finally I created a deployment file that contains all required configurations in order to accomplish the deployment.
The deployment file is shown above. I then executed the command 'kubectl apply -f deployment_local.yaml' and I came across with this error: &quot;*spec.template.metadata.labels:Invalid value map[string]string{&quot;app&quot;:&quot;nodejs\u00a0\u00a0&quot;}:<code>selector</code> does not match template <code>labels</code>&quot;</p>
<p>I'm tring to fix this bug but I could not fix it. Pls help understand this error because I'm strugglying for a lot of time.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-deployment
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nodejs
  template:
    metadata:
      labels:
        app: nodejs  
    spec:
      containers:
      - name: nodeapp
        image: lucasseabra/nodejs-starter
---
apiVersion: v1
kind: Service
metadata:
  name: nodejs-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    app: nodejs
  ports:
  - port: 3000
    targetPort: 3000
    nodePort: 30001

</code></pre>

Lucas Seabra
<p>As the error message was trying to tell you, there are two <a href="https://en.wikipedia.org/wiki/Non-breaking_space#Encodings" rel="nofollow noreferrer">&quot;non-breaking space&quot; characters</a> after <code>nodejs</code>: <code>map[string]string{&quot;app&quot;:&quot;nodejs\u00a0\u00a0&quot;}</code></p>
<p>I would guess it was a side-effect of copy-pasting from a webpage</p>
<p>If you even do a &quot;select all&quot; on your posted question here, you'll see that SO has converted the two characters into normal spaces, but they do show up in the selection extension past the &quot;nodejs&quot; text</p>
<p>If your editor is not able to show you the characters, then either manually retype the labels, or try copying this (which is just yours but with trailing spaces removed)</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-deployment
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nodejs
  template:
    metadata:
      labels:
        app: nodejs
    spec:
      containers:
      - name: nodeapp
        image: lucasseabra/nodejs-starter
---
apiVersion: v1
kind: Service
metadata:
  name: nodejs-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    app: nodejs
  ports:
  - port: 3000
    targetPort: 3000
    nodePort: 30001
</code></pre>
