<p>I think that there are lots of DevOps engineer realized this issue. Because I am from a software background. Explanations for syntax not enough for me. Below YAML is working for the Azure environment but not working for EKS and AWS.</p>
<p>Error:</p>
<pre><code> error validating data: ValidationError(Deployment.spec): unknown field &quot;spec&quot; in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false

</code></pre>
<p>My deployment yaml :</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name:  my-flask
spec:
  selector:
    matchLabels:
      app: my-flask
  replicas: 2
  template:
    metadata:
      labels:
        app: my-flask
  spec:
   containers:
     - name: my-flask
       image: yusufkaratoprak/awsflaskeks:latest
       ports:
         - containerPort: 5000
       
</code></pre>
<p><a href="https://i.stack.imgur.com/6adsp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6adsp.png" alt="enter image description here" /></a></p>

Penguen
<p>there is some indentation problem with your yamls.
the field second<code>spec</code> is under the template.<br />
will also encourage you to see the official docs of <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">kubernetes_deployment</a></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name:  my-flask
spec:
  selector:
    matchLabels:
      app: my-flask
  replicas: 2
  template:
    metadata:
      labels:
        app: my-flask
    spec:
    containers:
        - name: my-flask
          image: yusufkaratoprak/awsflaskeks:latest
          ports:
            - containerPort: 5000
</code></pre>
