一千萬個為什麽

搜索

當我遇到“服務器無法找到請求的資源”錯誤時,如何讓Kubernetes工作?



我無法創建一個kubernetes吊艙。我只是將Kubernetes部署到Ubuntu 16.04。

我有這個as.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

我得到這個:

服務器錯誤(NotFound):服務器找不到請求   資源

我期望上述命令創建一個窗格。

I ran this: 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 產生

服務器沒有資源類型“namespaces”

$ kubectl 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”,編譯器:“gc”,平臺:“linux/amd64”}服務器   版本:version.Info {Major:“1”,Minor:“0”,GitVersion:“v1.0.3”,   GitCommit: “61c6ac5f350253a4dc002aee97b7db7ff01ee4ca”   GitTreeState:“clean”,BuildDate:“”,GoVersion:“”,編譯器:“”,   平臺: “”}

更新1/15/18 我如何獲得一些要返回的命名空間?

轉載註明原文: 當我遇到“服務器無法找到請求的資源”錯誤時,如何讓Kubernetes工作?

一共有 1 個回答:

看起來你的k8s集群沒有得到很好的部署。我已經驗證它可以通過使用問題中定義的模板來部署nginx。

與您的群集不同,我使用的群集有幾個k8s映像來承載儀表板等。

        "Images": [
            {
                "Names": [
                    "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.3"
                ],
                "SizeBytes": 138972432
            },
            {
                "Names": [
                    "gcr.io/google_containers/[email protected]: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