我无法创建kubernetes容器。我刚刚将Kubernetes部署到Ubuntu 16.04。

我将其作为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


我运行以下命令:kubectl create -f a.yml

我得到了:


服务器错误(未找到):服务器找不到请求的资源



我希望上面的命令可以创建一个pod。

我运行了这个命令:kubectl cluster-info dump

我知道了:

{
    "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)

<

我在做什么错?

更新12/26/17

命令kubectl get ns产生


服务器没有资源类型为“命名空间”


$ kubectl version


客户端版本:version.Info {主要:“ 1”,次要: “ 9”,
GitVersion:“ v1.9.0”,
GitCommit:“ 925c127ec6b946659ad0fd596fa959be43f0cc05”,
GitTreeState:“ clean”,BuildDate:“ 2017-12-15T21:07:38Z”,
GoVersion:“ go1.9.2”,编译器:“ gc”,平台:“ linux / amd64”}服务器
版本:version.Info {主要:“ 1”,次要:“ 0”,GitVersion :“ v1.0.3”,
GitCommi t:“ 61c6ac5f350253a4dc002aee97b7db7ff01ee4ca”,
GitTreeState:“ clean”,BuildDate:“”,GoVersion:“”,编译器:“”,
平台:“”}


更新18年1月15日
如何获得一些要返回的命名空间?

评论

如果运行kubectl get ns会发生什么?

您正在使用哪个版本的Kubernetes?

图片:null,您要的是一个名为“ nginx”的图片,它看起来不像注册表图片名称,因此我想k8不知道该怎么做

#1 楼

按照https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin:


您必须使用一个未成年人内的kubectl版本集群的版本差异。例如,v1.2客户端应与v1.1,v1.2和v1.3主服务器一起使用。使用最新版本的kubectl有助于避免无法预料的问题。


因此您需要降级kubectl版本或升级集群版本。

#2 楼

您的k8s集群似乎部署得不好。我已经验证可以使用问题中定义的模板来部署nginx。

与您的集群相反,我正在使用的集群具有多个k8s图像来托管仪表板等。

        "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
            },


此外,为了部署映像,至少应返回一些名称空间。

$ kubectl get ns
NAME          STATUS    AGE
default       Active    37m
kube-public   Active    37m
kube-system   Active    37m