<p>I'm new to Kubernetes. I'm making my first ever attempt to deploy an application to Kubernetes and expose it to the public. However, when I try and deploy my configuration, I get this error:</p>
<blockquote>
<p>error: unable to recognize &quot;deployment.yml&quot;: no matches for kind &quot;Service&quot; in version &quot;apps/v1&quot;</p>
</blockquote>
<p>So, let's run through the details.</p>
<p>I'm on Ubuntu 18.04. I'm using MiniKube with VirtualBox as the HyperVisor driver. Here is all the version info:</p>
<pre><code>MiniKube = v1.11.0
VirtualBox = 6.1.0
Kubectl = Client Version 1.18.3, Server Version 1.18.3
</code></pre>
<p>The app I'm trying to deploy is a super-simple express.js app that returns Hello World on request.</p>
<pre><code>const express = require('express');

const app = express();

app.get('/hello', (req, res) =&gt; res.send('Hello World'));

app.listen(3000, () =&gt; console.log('Running'));
</code></pre>
<p>I have a build script I've used for deploying express apps to docker before that zips up all the source files. Then I've got my Dockerfile:</p>
<pre><code>FROM node:12.16.1

WORKDIR /usr/src/app

COPY ./build/TestServer-*.zip ./TestServer.zip
RUN unzip TestServer.zip

RUN yarn

CMD [&quot;yarn&quot;, &quot;start&quot;]
</code></pre>
<p>So now I run some commands. <code>eval $(minikube docker-env)</code> makes me use MiniKube's docker environment so I don't need to deploy this container to the cloud. <code>docker build -t testserver:v1 .</code> builds and tags the container.</p>
<p>Now, let's go to my deployment.yml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: testserver
spec:
  replicas: 1
  selector:
    matchLabels:
      app: testserver
  template:
    metadata:
      labels:
        app: testserver
    spec:
      containers:
        - name: testserver
          image: testserver:v1
          ports:
            - containerPort: 3000
          env:
          imagePullPolicy: Never
---
apiVersion: apps/v1
kind: Service
metadata:
  name: testserver
spec:
  selector:
    app: testserver
  ports:
    - port: 80
      targetPort: 3000
  type: LoadBalancer
</code></pre>
<p>I'm trying to create a deployment with a pod and a service to expose it. I'm sure there are various issues in here, this is the newest part to me and I'm still trying to learn and understand the spec. However, the problem I'm asking for help with occurs when I try to use this config. I run the create command, and get the error.</p>
<p><code>kubectl create -f deployment.yml</code></p>
<pre><code>deployment.apps/testserver created
error: unable to recognize &quot;deployment.yml&quot;: no matches for kind &quot;Service&quot; in version &quot;apps/v1&quot;
</code></pre>
<p>The result of this is I see my app listed as a deployment and as a pod, but the service part has failed. I've been scouring the internet for documentation on why this is happening, but I've got nothing.</p>

<p>A service is of <code>apiVersion: v1</code> instead of <code>apiVersion: apps/v1</code> (like a deployment). You can check it in the <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="noreferrer">official docs</a>. You  also need to use a Service of type NodePort (or ClusterIP) if you want to expose your deployment. Type LoadBalancer will not  work  in minikube. This is mostly used in k8s clusters managed in the cloud where a service of type LoadBalancer will create a loadbalancer (like an ALB in AWS).</p>

<p>To check the apigroup of a resource you can use: <code>kubectl api-resources</code></p>
