<h1>Problem</h1>
<p><a href="https://www.coursera.org/learn/gcp-fundamentals/lecture/umRjO/demo-getting-started-with-kubernetes-engine" rel="nofollow noreferrer">Coursera Google Cloud Fundamentals: Getting Started with Kubernetes Engine</a>
has the  instructions  to run and expose the pod. The demo video shows it is working.</p>
<p><a href="https://i.stack.imgur.com/FyD2I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FyD2I.png" alt="enter image description here" /></a>
However, it causes the error in my execution. How to fix?</p>
<pre><code>kubectl run nginx --image=nginx:1.10.0
kubectl expose deployment nginx --type LoadBalancer --port 80 
---
Error from server (NotFound): deployments.apps &quot;nginx&quot; not found
</code></pre>
<h2>Environment</h2>
<p>GCP k8s.</p>
<pre><code>$ kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.1&quot;, GitCommit:&quot;632ed300f2c34f6d6d15ca4cef3d3c7073412212&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-08-19T15:45:37Z&quot;, GoVersion:&quot;go1.16.7&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20+&quot;, GitVersion:&quot;v1.20.8-gke.2100&quot;, GitCommit:&quot;4cd085fda961821985d176d25b67445c1efb6ba1&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-07-16T09:22:57Z&quot;, GoVersion:&quot;go1.15.13b5&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
WARNING: version difference between client (1.22) and server (1.20) exceeds the supported minor version skew of +/-1
</code></pre>

mon
<h1>Cause</h1>
<p><code>kubectl run</code> does not create <code>deployment</code>.</p>
<p><a href="https://github.com/ivanfioravanti/kubernetes-the-hard-way-on-azure/issues/31" rel="noreferrer">'Error from server (NotFound): deployments.extensions &quot;nginx&quot; not found' when exposing NodePort #31</a></p>
<blockquote>
<p>Did you create a pod with &quot;kubectl run&quot;? If yes, that doesn't create a deployment with (at least) kubectl v1.18.2, so instead use &quot;kubectl create deployment nginx --image=nginx:1.10.0&quot;</p>
</blockquote>
<h1>Fix</h1>
<p>Create a deployment as in <a href="https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/#creating-and-exploring-an-nginx-deployment" rel="noreferrer">Creating and exploring an nginx deployment</a> from a YAML or run <code>kubectl create deployment ...</code>.</p>
<pre><code>$ kubectl create deployment nginx --image=nginx:1.12.0
deployment.apps/nginx created

$ kubectl expose deployment nginx --type LoadBalancer --port 80
service/nginx exposed

$ kubectl get services
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)        AGE
kubernetes   ClusterIP      10.83.240.1    &lt;none&gt;           443/TCP        44m
nginx        LoadBalancer   10.83.246.84   35.225.127.227   80:30825/TCP   60s
</code></pre>
