<p>I am new to K8S and trying to create a deployment using the below YAML file.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: building-apps-deploy
  labels:
    app: kubeacademy
spec:
  replicas: 2
  selector:
    matchlabels:
      app: kubeacademy
  template:
    metadata:
      labels:
        app: kubeacademy
    spec:
      containers:
        - name: building-apps-containers
          image: 'lander2k2/building-apps:0.1'

</code></pre>
<p>I had the file validated by 3 online validator websites and all is coming back ok but when I run the command - <strong>kubectl apply -f deployment_yam27112022.yml</strong>, it is throwing the below error:
<em>Error from server (BadRequest): error when creating &quot;deployment_yam27112022.yml&quot;: Deployment in version &quot;v1&quot; cannot be handled as a Deployment: strict decoding error: unknown field &quot;spec.selector.matchlabels&quot;</em></p>
<p>I understand that the spec.selector.matchlables has some issue but cannot pinpoint the same.</p>
<p>Request the community help to resolve this situation and let me know if there are any online resources for validating the YAML files or generating ones which are recommended?</p>
<p><strong>Additional info:</strong></p>
<p>the pod was created successfully using below YAML file:</p>
<pre><code>apiVersion: v1              
kind: Pod
metadata:
    name: building-apps-pod
    labels:
        app: kubeacademy
spec:
    containers:
    - name: building-apps-container
      image: lander2k2/building-apps:0.1
</code></pre>
<p>command used for pod creation: <em>kubectl apply -f CreatePod22112022.yml</em></p>
<p>and the cluster was created using the command <em>kind create cluster --name demo271122</em></p>
<p>To conclude my question: was trying to create a deployment post creation of cluster and pod. the deployment command is failing again and again.</p>
<p>I have also gone through the questions with same / similar error messages on stack overflow but have not been able to resolve the issue - some suggestions to earlier question was to format the YAML file properly but have already tried the same using Notepad++ and online yaml validator websites.</p>
<p>Thank you in advance for your help.</p>
<p>Best Regards</p>

DT1421
<p>Your error message says:</p>
<pre><code>unknown field &quot;spec.selector.matchlabels&quot;
</code></pre>
<p>In your deployment, we can see the following:</p>
<pre><code>selector:
  matchlabels:
    app: kubeacademy
</code></pre>
<p>You meant to do this instead:</p>
<pre><code>selector:
  matchLabels:
    app: kubeacademy
</code></pre>
