<p>I'm seeing the following error when running a pod. I matched with the documentation in the Kubernetes webpage and it is the code is same as the one i have written below but Istill end up with the below error.</p>

<hr>

<p>error validating data: the server could not find the requested resource; if you choose to ignore these errors, turn validation off with --validate=false</p>

<hr>

<pre><code>apiVersion: v1
kind: pod
metadata:
  name: helloworld-deployment
  labels:
    app: helloworld
spec:
  containers:
  - name: helloworld
    image: anishanil/kubernetes:node
    ports:
      containerPort: 3000
     resources:
      limits:
        memory: "100Mi"
        cpu: "100m"
</code></pre>

<hr>

<pre><code>Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.1", GitCommit:"b0b7a323cc5a4a2019b2e9520c21c7830b7f708e", GitTreeState:"clean", BuildDate:"2017-04-03T20:44:38Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6+IKS", GitCommit:"44b769243cf9b3fe09c1105a4a8749e8ff5f4ba8", GitTreeState:"clean", BuildDate:"2019-08-21T12:48:49Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<hr>

<p>Any help is greatly appreciated</p>

<p>Thank you</p>

anish anil
<blockquote>
  <p>I matched with the documentation in the Kubernetes webpage and it is
  the code is same as the one i have written below...</p>
</blockquote>

<p>Could you link the fragment of documentation with which you compare your code ? As other people already suggested in their answers and comments, your <code>yaml</code> is not valid. Are you sure you're not using some outdated tutorial or docs ?</p>

<p><strong>Let's debug it together step by step:</strong></p>

<ol>
<li>When I use exactly the same code you posted in your question, the error message I got is quite different than the one you posted:</li>
</ol>

<blockquote>
  <p>error: error parsing pod.yml: error converting YAML to JSON: yaml:
  line 12: did not find expected key</p>
</blockquote>

<p>OK, so let's go to mentioned line 12 and check where can be the problem:</p>

<pre><code> 11     ports:
 12       containerPort: 3000
 13      resources:
 14       limits:
 15         memory: "100Mi"
 16         cpu: "100m"
</code></pre>

<p>Line 12 itself looks actually totally ok, so the problem should be elsewhere. Let's debug it further using <a href="http://www.yamllint.com/" rel="nofollow noreferrer">this</a> online yaml validator. It also suggests that this <code>yaml</code> is syntactically not correct however it pointed out different line:</p>

<blockquote>
  <p>(): did not find expected key while parsing a block mapping
  at line 9 column 5</p>
</blockquote>

<p>If you look carefully at the above quoted fragment of code, you may notice that the indentation level in line 13 looks quite strange. When you remove one unnecessary space right before <code>resources</code> ( it should be on the same level as ports ) <strong><a href="http://www.yamllint.com/" rel="nofollow noreferrer">yaml validador</a></strong> will tell you that your <code>yaml</code> syntax is correct. Although it may already be a valid <code>yaml</code> it does not mean that it is a valid input for <strong>Kubernetes</strong> which requires specific structure following certain rules.</p>

<ol start="2">
<li>Let's try it again... Now <code>kubectl apply -f pod.yml</code> returns quite different error:</li>
</ol>

<blockquote>
  <p>Error from server (BadRequest): error when creating "pod.yml": pod in
  version "v1" cannot be handled as a Pod: no kind "pod" is registered
  for version "v1" in scheme
  "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"</p>
</blockquote>

<p>Quick search will give you an answer to that as well. Proper value of <code>kind:</code> key is <code>Pod</code> but not <code>pod</code>.</p>

<ol start="3">
<li>Once we fixed that, let's run <code>kubectl apply -f pod.yml</code> again. Now it gives us back different error:</li>
</ol>

<blockquote>
  <p>error: error validating "pod.yml": error validating data:
  ValidationError(Pod.spec.containers[0].ports): invalid type for
  io.k8s.api.core.v1.Container.ports: got "map", expected "array";</p>
</blockquote>

<p>which is pretty self-explanatory and means that you are not supposed to use <strong>"map"</strong> in a place where an <strong>"array"</strong> was expected and the error message precisely pointed out where, namely: </p>

<p><code>Pod.spec.containers[0].ports</code>. </p>

<p>Let's correct this fragment:</p>

<pre><code>11     ports:
12       containerPort: 3000
</code></pre>

<p>In yaml formatting the <code>-</code> character implies the start of an array so it should look like this:</p>

<pre><code>11     ports:
12     - containerPort: 3000
</code></pre>

<ol start="4">
<li>If we run <code>kubectl apply -f pod.yml</code> again, we finally got the expected message:</li>
</ol>

<blockquote>
  <p>pod/helloworld-deployment created</p>
</blockquote>

<p>The final, correct version of the <code>Pod</code> definition looks as follows:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: helloworld-deployment
  labels:
    app: helloworld
spec:
  containers:
  - name: helloworld
    image: anishanil/kubernetes:node
    ports:
    - containerPort: 3000
    resources:
      limits:
        memory: "100Mi"
        cpu: "100m"
</code></pre>
