<p>I have a single image that I'm trying to deploy to an AKS cluster.  The image is stored in Azure container registry and I'm simply trying to apply the YAML file to get it loaded into AKS using the following command:</p>

<blockquote>
  <p>kubectl apply -f myPath\myimage.yaml</p>
</blockquote>

<p>kubectl keeps complaining that I'm missing the required "selector" field and that the field "spec" is unknown.  This seems like a basic image configuration so I don't know what else to try.</p>

<blockquote>
  <p>kubectl : error: error validating "myimage.yaml": error validating
  data:  [ValidationError(Deployment.spec): unknown field "spec" in
  io.k8s.api.apps.v1.DeploymentSpec, ValidationError(Deployment.spec):
  missing required field "selector"  in
  io.k8s.api.apps.v1.DeploymentSpec]; if you choose to ignore these
  errors, turn validation off with --validate=false At line:1 char:1</p>
</blockquote>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
    name: myimage
spec:
    replicas: 1
    template:
        metadata:
            labels:
                app: myimage
    spec:
        containers:
        - name: myimage
          image: mycontainers.azurecr.io/myimage:v1
          ports:
          - containerPort: 5000
</code></pre>

<p>As specified in the error message, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">deployments</a> require a selector field inside their spec. You can look at the link for some examples.</p>

<p>Also, do note that there are two spec fields. One for the deployment and one for the pod used as template. Your spec for the pod is misaligned. It should be one level deeper.</p>
