title: K8s deployment error: `selector` does not match template `labels`
body: <p>I'm trying to migrate from docker-compose to kubernetes. I had some issues with volume, so what I did is:</p>
  <pre><code>kompose convert --volumes hostPath
  </code></pre>
  <p>Then I had another issue</p>
  <pre><code>no matches for kind &quot;Deployment&quot; in version &quot;extensions/v1beta1&quot;
  </code></pre>
  <p>So I've changed ApiVersion from extensions/v1beta1 to app/v1 and added &quot;selector&quot;. Now I can't manage with that issue:</p>
  <pre><code>
  Error from server (Invalid): error when creating &quot;database-deployment.yaml&quot;: Deployment.apps &quot;database&quot; is invalid: spec.template.metadata.labels: Invalid value: map[string]string{&quot;io.kompose.service&quot;:&quot;database&quot;}: `selector` does not match template `labels`
  Error from server (Invalid): error when creating &quot;phpmyadmin-deployment.yaml&quot;: Deployment.apps &quot;phpmyadmin&quot; is invalid: spec.template.metadata.labels: Invalid value: map[string]string{&quot;io.kompose.service&quot;:&quot;phpmyadmin&quot;}: `selector` does not match template `labels`
  Error from server (Invalid): error when creating &quot;webserver-deployment.yaml&quot;: Deployment.apps &quot;webserver&quot; is invalid: spec.template.metadata.labels: Invalid value: map[string]string{&quot;io.kompose.service&quot;:&quot;webserver&quot;}: `selector` does not match template `labels`
  
  </code></pre>
  <p>database-deployment.yaml</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      kompose.cmd: kompose convert --volumes hostPath
      kompose.version: 1.19.0 (f63a961c)
    creationTimestamp: null
    labels:
      io.kompose.service: database
      app: database
    name: database
  spec:
    selector:
      matchLabels:
        app: database
    template:
      metadata:
        labels:
          io.kompose.service: database
    replicas: 1
    strategy: {}
    template:
      metadata:
        annotations:
          kompose.cmd: kompose convert --volumes hostPath
          kompose.version: 1.19.0 (f63a961c)
        creationTimestamp: null
        labels:
          io.kompose.service: database
      spec:
        containers:
        - env:
          - name: MYSQL_DATABASE
            value: Bazadanerro
          - name: MYSQL_PASSWORD
            value: P@$$w0rd
          - name: MYSQL_ROOT_PASSWORD
            value: P@$$w0rd
          - name: MYSQL_USER
            value: dockerro
          image: mariadb
          name: mysql
          resources: {}
        restartPolicy: Always
  status: {}
  </code></pre>
  <p>phpmyadmin-deployment.yaml</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      kompose.cmd: kompose convert --volumes hostPath
      kompose.version: 1.19.0 (f63a961c)
    creationTimestamp: null
    labels:
      io.kompose.service: phpmyadmin
      app: phpmyadmin
    name: phpmyadmin
  spec:
    selector:
      matchLabels:
        app: phpmyadmin
    template:
      metadata:
        labels:
          io.kompose.service: database
    replicas: 1
    strategy: {}
    template:
      metadata:
        annotations:
          kompose.cmd: kompose convert --volumes hostPath
          kompose.version: 1.19.0 (f63a961c)
        creationTimestamp: null
        labels:
          io.kompose.service: phpmyadmin
      spec:
        containers:
        - env:
          - name: MYSQL_PASSWORD
            value: P@$$w0rd
          - name: MYSQL_ROOT_PASSWORD
            value: P@$$w0rd
          - name: MYSQL_USER
            value: dockerro
          - name: PMA_HOST
            value: database
          - name: PMA_PORT
            value: &quot;3306&quot;
          image: phpmyadmin/phpmyadmin
          name: phpmyadmins
          ports:
          - containerPort: 80
          resources: {}
        restartPolicy: Always
  status: {}
  </code></pre>
  <p>And webserver-deployment.yaml</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      kompose.cmd: kompose convert --volumes hostPath
      kompose.version: 1.19.0 (f63a961c)
    creationTimestamp: null
    labels:
      io.kompose.service: webserver
      app: webserverro
    name: webserver
  spec:
    selector:
      matchLabels: 
        app: webserverro
    template:
      metadata:
        labels:
          io.kompose.service: webserver
    replicas: 1
    strategy:
      type: Recreate
    template:
      metadata:
        annotations:
          kompose.cmd: kompose convert --volumes hostPath
          kompose.version: 1.19.0 (f63a961c)
        creationTimestamp: null
        labels:
          io.kompose.service: webserver
      spec:
        containers:
        - image: webserver
          name: webserverro
          ports:
          - containerPort: 80
          resources: {}
          volumeMounts:
          - mountPath: /var/www/html
            name: webserver-hostpath0
        restartPolicy: Always
        volumes:
        - hostPath:
            path: /root/webserverro/root/webserverro
          name: webserver-hostpath0
  status: {}
  </code></pre>
  <p>What am I doing wrong?</p>