<p>While trying to perform <code>helm install</code></p>

<blockquote>
  <p>Error: unable to build kubernetes objects from release manifest:
  [unable to recognize "": no matches for kind "Service" in version
  "extensions/v1beta1", error validating "": error validating data:
  ValidationError(Deployment.spec): missing required field "selector" in
  io.k8s.api.apps.v1.DeploymentSpec]</p>
</blockquote>

<p>My <code>service.yaml</code> looks like below</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Service
metadata:
  name: helm-xxx-helper-api
spec:
  type: NodePort
  ports:
    - nodePort: 31235
      port: 80
      targetPort: 8080
  selector:
     app: helm-xxx-helper
</code></pre>

<p>My <code>deployment.yaml</code> </p>

<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helm-xxx-helper
spec:
  replicas: 2
  selector:
    matchLabels:
    name: helm-xxx-helper
  template:
    metadata:
      labels:
        app: helm-xxx-helper
    spec:
      containers:
      - name: helm-xxx-helper
        image: xxxxxxxxx:5001/devops/xxx-helper:latest
        imagePullPolicy: Always
        env:
          - name: XXX_STAGE
            value: "DEV"
        ports:
        - containerPort: 8080
</code></pre>

<p>What could be the issue here?</p>

<p>As you received this error it means that you are using version Kubernetes 1.16 or newer.</p>

<p><strong>Issue 1</strong> - With <code>Service</code></p>

<p>In this version many <code>apiVersion</code> has been changed (Deployments, StatefulSet, Service). More details can be found <a href="https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/" rel="noreferrer">here</a>.</p>

<p>In Kubernetes 1.16 you need to use <code>apiVersion: v1</code> for <code>service</code>. Otherwise you will receive errors like</p>

<pre><code>error: unable to recognize "STDIN": no matches for kind "Service" in version "extensions/v1beta1"
error: unable to recognize "STDIN": no matches for kind "Service" in version "extensions/v1"
error: unable to recognize "STDIN": no matches for kind "Service" in version "apps/v1"
</code></pre>

<p><strong>Issue 2</strong> - With <code>Deployment</code>.</p>

<ul>
<li><code>spec.selector.matchLabels</code> does not contain value like <code>name</code>. You need to use value from <code>labels</code>. So in this case instead of <code>name: helm-xxx-helper</code> you need to use <code>app: helm-xxx-helper</code> otherwise you will receive error like:</li>
</ul>

<pre><code>The Deployment "helm-xxx-helper" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"helm-xxx-helper"}: `selector` does not match template `labels`
</code></pre>

<ul>
<li>wrong YAML format. In your code you have</li>
</ul>

<pre><code>...
selector:
  matchLabels:
  name: helm-xxx-helper
...
</code></pre>

<p>Value for <code>matchLabels</code> should be under 3rd letter (t). Also as I mentioned in previous point you need to change <code>name</code> to <code>app</code></p>

<p>Proper format with correct valye of <code>matchLables</code>:</p>

<pre><code>...
selector:
  matchLabels:
    app: helm-xxx-helper
...
</code></pre>

<p>You can read about <code>Labels</code> and <code>Selectors</code> <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="noreferrer">here</a>.</p>

<p>As you mentioned it is <code>HELM</code>, you will need to change <code>Kubernetes version</code> to older than 1.16 or change <code>apiVersion</code> in each object YAML in  <code>template</code> directory.
There was already a similar case. Please check <a href="https://stackoverflow.com/a/58482194/11148139">this thread</a> for more information.</p>

<p>Below both YAMLs which will create <code>Service</code> and <code>Deployment</code>. Tested on Kubernetes 1.16.1.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: helm-xxx-helper-api
spec:
  type: NodePort
  ports:
    - nodePort: 31235
      port: 80
      targetPort: 8080
  selector:
    app: helm-xxx-helper
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helm-xxx-helper
spec:
  replicas: 2
  selector:
    matchLabels:
      app: helm-xxx-helper
  template:
    metadata:
      labels:
        app: helm-xxx-helper
    spec:
      containers:
      - name: helm-xxx-helper
        image: nginx # As I dont have your image ive put nginx
        imagePullPolicy: Always
        env:
          - name: XXX_STAGE
            value: "DEV"
        ports:
        - containerPort: 8080
</code></pre>
