简体   繁体   English

kubectl get 节点无法连接到 AWS EC2 实例上的服务器

[英]kubectl get nodes unable to connect to the server on AWS EC2 Instance

I have deployed kubernetes cluster on AWS EC2 Ubuntu Nodes, one master node and one worker node.我已经在 AWS EC2 Ubuntu 节点上部署了 kubernetes 集群,一个主节点和一个工作节点。 Its a free tier t2.micro machine with 1 CPU.它是带有 1 个 CPU 的免费层 t2.micro 机器。

I installed and configured everything and on day 1 everything works fine.我安装并配置了所有东西,第一天一切正常。 kubectl get nodes command was responding without any delay and i was able to create MYSQL deployment. kubectl get nodes命令立即响应,我能够创建 MYSQL 部署。

Next day when i tried kubectl get nodes i was getting The connection to the server :6443 was refused - did you specify the right host or port?第二天,当我尝试kubectl get nodes我得到了与服务器的连接:6443 被拒绝 - 您是否指定了正确的主机或端口? and even sometimes i am getting Unable to connect to the server: net/http: TLS handshake timeout甚至有时我无法连接到服务器:net/http:TLS 握手超时

I checked the following things to verify whether kubernetes is working or not sudo systemctl status kubelet it was in active status我检查了以下内容以验证 kubernetes 是否正在工作sudo systemctl status kubelet它处于活动状态

Even its surprising that sometime kubectl get nodes works perfectly and sometime it return The connection to the server :6443 was refused - did you specify the right host or port?甚至令人惊讶的是,有时kubectl get nodes运行良好,有时它返回与服务器的连接:6443 被拒绝 - 您是否指定了正确的主机或端口?

I am not able to understand how to fix this issue ?我不明白如何解决这个问题?

This could be caused by a mismatch between the actual master node IP ( apiserver ) and the server entry configured in your ~/.kube/config .这可能是由于实际主节点 IP ( apiserver ) 与您的~/.kube/config配置的server条目不匹配造成的。 Verify that they both match and if not, just update the server entry.验证它们是否匹配,如果不匹配,只需更新server条目。

Keep in mind that EC2 instances can and will fail (I've seen them randomly crashing even on managed clusters).请记住,EC2 实例可能并且将会失败(我已经看到它们甚至在托管集群上随机崩溃)。 This could explain why one day your control plane was accessible on one IP and no longer accessible on the next day.这可以解释为什么有一天你的控制平面可以通过一个 IP 访问,而在第二天不再访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM