5

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?

  • What happens if kubectl get ns is run? – 030 Dec 26 '17 at 11:14
  • What version of Kubernetes are you using? – Xiong Chiamiov Dec 26 '17 at 18:52
  • 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 – Tensibai Dec 26 '17 at 19:45
2

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.