首页 > 解决方案 > AWS kubectl:无法连接到服务器:EOF

问题描述

我是 Kubernetes 新手,正在尝试在 AWS 上创建集群。我无法运行kubectl命令并获得无法连接服务器:EOF

在过去的两天里,我一直在尝试各种论坛和帮助,但不确定缺少什么。

脚步:

我已经启动了一个 t2.micro Ubuntu EC2 实例。

以下是安装的软件的详细信息:

$ kops version
Version 1.10.0 (git-8b52ea6d1)

$ aws --version
aws-cli/1.16.43 Python/3.6.6 Linux/4.15.0-1021-aws botocore/1.12.33

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", 
GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", 
BuildDate:"2018-10-24T06:54:59Z", GoVersion:"go1.10.4", Compiler:"gc", 
Platform:"linux/amd64"}
Unable to connect to the server: EOF

我在定义 AWS 访问密钥/秘密密钥和 S3 存储桶后创建集群:

 $ kops create cluster clusters.k8s.local --zones us-east-1a --ssh-public-key kubernetes.pub --yes

我得到以下输出:

$ kops create cluster clusters.k8s.local --zones us-east-1a --ssh-public-key kubernetes.pub --yes
I1028 15:07:44.695579   10142 create_cluster.go:1351] Using SSH public key: kubernetes.pub
I1028 15:07:45.604469   10142 create_cluster.go:480] Inferred --cloud=aws from zone "us-east-1a"
I1028 15:07:46.037436   10142 subnets.go:184] Assigned CIDR 172.20.32.0/19 to subnet us-east-1a
I1028 15:07:49.847838   10142 apply_cluster.go:505] Gossip DNS: skipping DNS validation
I1028 15:07:50.474329   10142 executor.go:103] Tasks: 0 done / 77 total; 30 can run
I1028 15:07:51.670973   10142 vfs_castore.go:735] Issuing new certificate: "apiserver-aggregator-ca"
I1028 15:07:51.819791   10142 vfs_castore.go:735] Issuing new certificate: "ca"
I1028 15:07:52.756166   10142 executor.go:103] Tasks: 30 done / 77 total; 24 can run
I1028 15:07:54.645080   10142 vfs_castore.go:735] Issuing new certificate: "apiserver-proxy-client"
I1028 15:07:55.018900   10142 vfs_castore.go:735] Issuing new certificate: "apiserver-aggregator"
I1028 15:07:55.250726   10142 vfs_castore.go:735] Issuing new certificate: "kube-proxy"
I1028 15:07:55.295112   10142 vfs_castore.go:735] Issuing new certificate: "kube-scheduler"
I1028 15:07:55.381353   10142 vfs_castore.go:735] Issuing new certificate: "kube-controller-manager"
I1028 15:07:55.646626   10142 vfs_castore.go:735] Issuing new certificate: "kops"
I1028 15:07:56.694727   10142 vfs_castore.go:735] Issuing new certificate: "kubecfg"
I1028 15:07:56.837301   10142 vfs_castore.go:735] Issuing new certificate: "kubelet-api"
I1028 15:07:56.955183   10142 vfs_castore.go:735] Issuing new certificate: "kubelet"
I1028 15:07:57.546052   10142 executor.go:103] Tasks: 54 done / 77 total; 19 can run
I1028 15:07:59.426632   10142 executor.go:103] Tasks: 73 done / 77 total; 3 can run
I1028 15:08:00.563120   10142 vfs_castore.go:735] Issuing new certificate: "master"
I1028 15:08:01.146029   10142 executor.go:103] Tasks: 76 done / 77 total; 1 can run
I1028 15:08:01.784444   10142 executor.go:103] Tasks: 77 done / 77 total; 0 can run
I1028 15:08:01.937677   10142 update_cluster.go:290] Exporting kubecfg for cluster
kops has set your kubectl context to clusters.k8s.local

Cluster is starting.  It should be ready in a few minutes.

Suggestions:
* validate cluster: kops validate cluster
* list nodes: kubectl get nodes --show-labels
* ssh to the master: ssh -i ~/.ssh/id_rsa admin@api.clusters.k8s.local
* the admin user is specific to Debian. If not using Debian please use the appropriate user based on your OS.   
* read about installing addons at: https://github.com/kubernetes/kops/blob/master/docs/addons.md.

我看到在我的 S3 存储桶下创建的 clusters.k8s.local。

$ kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: EOF

验证 kops 集群:

$ kops validate cluster
Using cluster from kubectl context: clusters.k8s.local

Validating cluster clusters.k8s.local


unexpected error during validation: error listing nodes: Get https://api-clusters-k8s-local-k5ptn2-2092608752.us-east-1.elb.amazonaws.com/api/v1/nodes: EOF

当我运行 nslookup 命令时:

$ nslookup clusters.k8s.local
Server:         127.0.0.53
Address:        127.0.0.53#53

** server can't find clusters.k8s.local: SERVFAIL

标签: amazon-web-serviceskuberneteskubectlkops

解决方案


推荐阅读