Answers: <p>It looks like your k8s cluster has not been deployed well. I have verified that it works to deploy the nginx by using the template as defined in the question.</p>
  
  <p>In contrast to your cluster, the cluster I am using has several k8s images to host the dashboard etc.</p>
  
  <pre><code>        "Images": [
              {
                  "Names": [
                      "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.3"
                  ],
                  "SizeBytes": 138972432
              },
              {
                  "Names": [
                      "gcr.io/google_containers/kubernetes-dashboard-amd64@sha256:71a0de5c6a21cb0c2fbcad71a4fef47acd3e61cd78109822d35e1742f9d8140d",
                      "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.0"
                  ],
                  "SizeBytes": 119155776
              },
  </code></pre>
  
  <p>Also in order to deploy images, at least some namespaces should be returned. </p>
  
  <pre><code>$ kubectl get ns
  NAME          STATUS    AGE
  default       Active    37m
  kube-public   Active    37m
  kube-system   Active    37m
  </code></pre>
  
Answers: CC BY-SA 3.0
Answers: 2017-12-30T17:21:12.650Z
Answers: 2017-12-30T17:52:04.477Z
Answers: 2017-12-30T17:52:04.477Z
Answers: 030
Answers: <p>As per <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin" rel="noreferrer">https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin</a>:</p>
  
  <blockquote>
    <p>You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.</p>
  </blockquote>
  
  <p>So you need to either downgrade your kubectl version or upgrade your cluster version.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-05-14T03:35:23.607Z
Answers: 2019-06-24T14:36:14.530Z
Answers: 2019-06-24T14:36:14.530Z
Answers: Map
Body: <p>I cannot create a kubernetes pod.  I just deployed Kubernetes to Ubuntu 16.04.</p>
  
  <p>I have this as a.yml:</p>
  
  <pre><code>apiVersion: v1
  kind: ReplicationController
  metadata:
    name: nginx
  spec:
    replicas: 2
    selector:
      app: nginx
    template:
      metadata:
        name: nginx
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: nginx
          ports:
          - containerPort: 80
  </code></pre>
  
  <p>I run this: <code>kubectl create -f a.yml</code></p>
  
  <p>I get this: </p>
  
  <blockquote>
    <p>Error from server (NotFound): the server could not find the requested
    resource</p>
  </blockquote>
  
  <p>I expected the above command to create a pod.</p>
  
  <p>I ran this: <code>kubectl cluster-info dump</code></p>
  
  <p>I got this:</p>
  
  <pre><code>{
      "selfLink": "/api/v1/nodes",
      "resourceVersion": "185",
      "Items": [
          {
              "name": "ip-10-10-10-10",
              "selfLink": "/api/v1/nodes/ip-10-10-10-10",
              "uid": "cdc51051-ea07-11e7-b7ae-025c31abfac0",
              "resourceVersion": "185",
              "creationTimestamp": "2017-12-26T06:41:29Z",
              "labels": {
                  "kubernetes.io/hostname": "ip-10-10-10-10"
              },
              "Spec": {
                  "PodCIDR": "",
                  "ExternalID": "ip-10-10-10-10",
                  "ProviderID": "",
                  "Unschedulable": false,
                  "Taints": null,
                  "ConfigSource": null
              },
              "Status": {
                  "Capacity": {
                      "cpu": "0",
                      "memory": "0",
                      "pods": "40"
                  },
                  "Allocatable": {
                      "cpu": "0",
                      "memory": "0",
                      "pods": "40"
                  },
                  "Phase": "",
                  "Conditions": [
                      {
                          "Type": "Ready",
                          "Status": "True",
                          "LastHeartbeatTime": "2017-12-26T07:03:01Z",
                          "LastTransitionTime": "2017-12-26T06:41:29Z",
                          "Reason": "kubelet is posting ready status",
                          "Message": ""
                      }
                  ],
                  "Addresses": [
                      {
                          "Type": "LegacyHostIP",
                          "Address": "10.10.10.10"
                      }
                  ],
                  "DaemonEndpoints": {
                      "KubeletEndpoint": {
                          "Port": 0
                      }
                  },
                  "NodeInfo": {
                      "MachineID": "",
                      "SystemUUID": "",
                      "BootID": "",
                      "KernelVersion": "",
                      "OSImage": "",
                      "ContainerRuntimeVersion": "",
                      "KubeletVersion": "",
                      "KubeProxyVersion": "",
                      "OperatingSystem": "",
                      "Architecture": ""
                  },
                  "Images": null,
                  "VolumesInUse": null,
                  "VolumesAttached": null
              }
          }
      ] } {
      "selfLink": "/api/v1/namespaces/kube-system/events",
      "resourceVersion": "185",
      "Items": [] } {
      "selfLink": "/api/v1/namespaces/kube-system/replicationcontrollers",
      "resourceVersion": "185",
      "Items": [] } {
      "selfLink": "/api/v1/namespaces/kube-system/services",
      "resourceVersion": "185",
      "Items": [] } Error from server (NotFound): the server could not find the requested resource (get daemonsets.extensions)
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Update 12/26/17</p>
  
  <p>The command <code>kubectl get ns</code> produces </p>
  
  <blockquote>
    <p>the server doesn't have a resource type "namespaces"</p>
  </blockquote>
  
  <p>$ <code>kubectl version</code></p>
  
  <blockquote>
    <p>Client Version: version.Info{Major:"1", Minor:"9",
    GitVersion:"v1.9.0",
    GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05",
    GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z",
    GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"} Server
    Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.3",
    GitCommit:"61c6ac5f350253a4dc002aee97b7db7ff01ee4ca",
    GitTreeState:"clean", BuildDate:"", GoVersion:"", Compiler:"",
    Platform:""}</p>
  </blockquote>
  
  <p>Update 1/15/18
  How do I get some namespaces to be returned?</p>
  
Comments: CC BY-SA 3.0
Comments: 2017-12-26T11:14:42.977Z
Comments: What happens if `kubectl get ns` is run?
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2017-12-26T18:52:22.270Z
Comments: What version of Kubernetes are you using?
Comments: Xiong Chiamiov
Comments: CC BY-SA 3.0
Comments: 2017-12-26T19:45:55.803Z
Comments: Images: null and you're asking for an image named 'nginx', that doesn't looks like a registry image name, as such I guess k8s have no idea what to do
Comments: Tensibai
Tags: <kubernetes>
Title: How do I get Kubernetes to work when I get an error "the server could not find the requested resource"?
UserDisplayName: Jermoe
ThreadText: # How do I get Kubernetes to work when I get an error "the server could not find the requested resource"?
  
  (Asked by: username_0 on 2017-12-26)
  
  I cannot create a kubernetes pod. I just deployed Kubernetes to Ubuntu 16.04.
  
  I have this as a.yml:
  
  ```
  apiVersion: v1
  kind: ReplicationController
  metadata:
    name: nginx
  spec:
    replicas: 2
    selector:
      app: nginx
    template:
      metadata:
        name: nginx
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: nginx
          ports:
          - containerPort: 80
  
  ```
  
  I run this: `kubectl create -f a.yml`
  
  I get this:
  
  > Error from server (NotFound): the server could not find the requested
  > resource
  
  I expected the above command to create a pod.
  
  I ran this: `kubectl cluster-info dump`
  
  I got this:
  
  ```
  {
      "selfLink": "/api/v1/nodes",
      "resourceVersion": "185",
      "Items": [
          {
              "name": "ip-10-10-10-10",
              "selfLink": "/api/v1/nodes/ip-10-10-10-10",
              "uid": "cdc51051-ea07-11e7-b7ae-025c31abfac0",
              "resourceVersion": "185",
              "creationTimestamp": "2017-12-26T06:41:29Z",
              "labels": {
                  "kubernetes.io/hostname": "ip-10-10-10-10"
              },
              "Spec": {
                  "PodCIDR": "",
                  "ExternalID": "ip-10-10-10-10",
                  "ProviderID": "",
                  "Unschedulable": false,
                  "Taints": null,
                  "ConfigSource": null
              },
              "Status": {
                  "Capacity": {
                      "cpu": "0",
                      "memory": "0",
                      "pods": "40"
                  },
                  "Allocatable": {
                      "cpu": "0",
                      "memory": "0",
                      "pods": "40"
                  },
                  "Phase": "",
                  "Conditions": [
                      {
                          "Type": "Ready",
                          "Status": "True",
                          "LastHeartbeatTime": "2017-12-26T07:03:01Z",
                          "LastTransitionTime": "2017-12-26T06:41:29Z",
                          "Reason": "kubelet is posting ready status",
                          "Message": ""
                      }
                  ],
                  "Addresses": [
                      {
                          "Type": "LegacyHostIP",
                          "Address": "10.10.10.10"
                      }
                  ],
                  "DaemonEndpoints": {
                      "KubeletEndpoint": {
                          "Port": 0
                      }
                  },
                  "NodeInfo": {
                      "MachineID": "",
                      "SystemUUID": "",
                      "BootID": "",
                      "KernelVersion": "",
                      "OSImage": "",
                      "ContainerRuntimeVersion": "",
                      "KubeletVersion": "",
                      "KubeProxyVersion": "",
                      "OperatingSystem": "",
                      "Architecture": ""
                  },
                  "Images": null,
                  "VolumesInUse": null,
                  "VolumesAttached": null
              }
          }
      ] } {
      "selfLink": "/api/v1/namespaces/kube-system/events",
      "resourceVersion": "185",
      "Items": [] } {
      "selfLink": "/api/v1/namespaces/kube-system/replicationcontrollers",
      "resourceVersion": "185",
      "Items": [] } {
      "selfLink": "/api/v1/namespaces/kube-system/services",
      "resourceVersion": "185",
      "Items": [] } Error from server (NotFound): the server could not find the requested resource (get daemonsets.extensions)
  
  ```
  
  What am I doing wrong?
  
  Update 12/26/17
  
  The command `kubectl get ns` produces
  
  > the server doesn't have a resource type "namespaces"
  
  $ `kubectl version`
  
  > Client Version: version.Info{Major:"1", Minor:"9",
  > GitVersion:"v1.9.0",
  > GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05",
  > GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z",
  > GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"} Server
  > Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.3",
  > GitCommit:"61c6ac5f350253a4dc002aee97b7db7ff01ee4ca",
  > GitTreeState:"clean", BuildDate:"", GoVersion:"", Compiler:"",
  > Platform:""}
  
  Update 1/15/18
  How do I get some namespaces to be returned?
  
  **Tags:** kubernetes
  
  > **Comments:**
  > **username_1**: What happens if `kubectl get ns` is run?  
  > **username_2**: What version of Kubernetes are you using?  
  > **username_3**: Images: null and you're asking for an image named 'nginx', that doesn't looks like a registry image name, as such I guess k8s have no idea what to do  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2019-05-14. Score: 7 | Accepted answer
  
  As per <https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin>:
  
  > You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.
  
  So you need to either downgrade your kubectl version or upgrade your cluster version.
  
  
  ---
  
  ### Answer by username_1 on 2017-12-30. Score: 2
  
  It looks like your k8s cluster has not been deployed well. I have verified that it works to deploy the nginx by using the template as defined in the question.
  
  In contrast to your cluster, the cluster I am using has several k8s images to host the dashboard etc.
  
  ```
          "Images": [
              {
                  "Names": [
                      "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.3"
                  ],
                  "SizeBytes": 138972432
              },
              {
                  "Names": [
                      "gcr.io/google_containers/kubernetes-dashboard-amd64@sha256:71a0de5c6a21cb0c2fbcad71a4fef47acd3e61cd78109822d35e1742f9d8140d",
                      "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.0"
                  ],
                  "SizeBytes": 119155776
              },
  
  ```
  
  Also in order to deploy images, at least some namespaces should be returned.
  
  ```
  $ kubectl get ns
  NAME          STATUS    AGE
  default       Active    37m
  kube-public   Active    37m
  kube-system   Active    37m
  
  ```
  
  
  ---
  
  