<p>I am trying to deploy this kubernetes deployment; however, when ever I do: <code>kubectl apply -f es-deployment.yaml</code> it throws the error: <code>Error:  `selector` does not match template `labels</code><br>
I have already tried to add the selector, matchLabels under the specs section but it seems like that did not work.  Below is my yaml file.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f docker-compose.yaml --volumes hostPath
    kompose.version: 1.19.0 (f63a961c)
  creationTimestamp: null
  labels:
    io.kompose.service: elasticsearchconnector
  name: elasticsearchconnector
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f docker-compose.yaml --volumes hostPath
        kompose.version: 1.19.0 (f63a961c)
      creationTimestamp: null
      labels:
        io.kompose.service: elasticsearchconnector
    spec:
      selector: 
        matchLabels:
          app: elasticsearchconnector
      containers:
      - env:
          - [env stuff]
        image: confluentinc/cp-kafka-connect:latest
        name: elasticsearchconnector
        ports:
        - containerPort: 28082
        resources: {}
        volumeMounts:
        - mountPath: /etc/kafka-connect
          name: elasticsearchconnector-hostpath0
        - mountPath: /etc/kafka-elasticsearch
          name: elasticsearchconnector-hostpath1
        - mountPath: /etc/kafka
          name: elasticsearchconnector-hostpath2
      restartPolicy: Always
      volumes:
      - hostPath:
          path: /home/centos/Sprint0Demo/DockerScriptsAWS/ServersCompose/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-connect
        name: elasticsearchconnector-hostpath0
      - hostPath:
          path: /home/centos/Sprint0Demo/DockerScriptsAWS/ServersCompose/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-elasticsearch
        name: elasticsearchconnector-hostpath1
      - hostPath:
          path: /home/centos/Sprint0Demo/DockerScriptsAWS/ServersCompose/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafak
        name: elasticsearchconnector-hostpath2
status: {}
</code></pre>

<p>Your labels and selectors are misplaced.</p>

<p>First, you need to specify which pods the deployment will control:</p>

<pre><code>spec:
  replicas: 1
  selector: 
    matchLabels:
      app: elasticsearchconnector
</code></pre>

<p>Then you need to label the pod properly:</p>

<pre><code>  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f docker-compose.yaml --volumes hostPath
        kompose.version: 1.19.0 (f63a961c)
      creationTimestamp: null
      labels:
        io.kompose.service: elasticsearchconnector
        app: elasticsearchconnector
    spec:
      containers:
</code></pre>
