[英]The connection to the server xxxx:6443 was refused - did you specify the right host or port?
If you followed only mentioned docs it means that you have only installed kubeadm
, kubectl
and kubelet
.如果您只关注提到的文档,则意味着您只安装了kubeadm
、 kubectl
和kubelet
。
If you want to run kubeadm
properly you need to do 3 steps more.如果你想正确运行kubeadm
,你需要多做 3 步。
1. Install docker 1.安装docker
Install Docker ubuntu version .安装Docker ubuntu 版本。 If you are using another system chose it from left menu side.如果您使用的是另一个系统,请从左侧菜单中选择它。
Why:为什么:
If you will not install docker you will receive errror like below:如果您不安装 docker,您将收到如下错误:
preflight] WARNING: Couldn't create the interface used for talking to the container runtime: docker is required for container runtime: exec: "docker": e
xecutable file not found in $PATH
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
[ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
2. Initialization of kubeadm
kubeadm
的初始化
You have installed properly kubeadm
and docker
but now you need to initialize kubeadm
.您已经正确安装了kubeadm
和docker
但现在您需要初始化kubeadm
。 Docs can be found here文档可以在这里找到
In short version you have to run command简而言之,您必须运行命令
$ sudo kubeadm init
After initialization you will receive information to run commands like:初始化后,您将收到运行命令的信息,例如:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
and token to join another VM to cluster.和令牌以将另一个 VM 加入集群。 It looks like看起来像
kubeadm join 10.166.XX.XXX:6443 --token XXXX.XXXXXXXXXXXX \
--discovery-token-ca-cert-hash sha256:aXXXXXXXXXXXXXXXXXXXXXXXX166b0b446986dd05c1334626aa82355e7
If you want to run some special action in init phase please check this docs .如果您想在初始化阶段运行一些特殊操作,请查看此文档。
3. Change node status to Ready
3. 将节点状态更改为Ready
After previous step you will be able to execute在上一步之后,您将能够执行
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ubuntu-kubeadm NotReady master 4m29s v1.16.2
But your node will be in NotReady
status.但是您的节点将处于NotReady
状态。 If you will describe it $ kubectl describe node
you will see error:如果你要描述它$ kubectl describe node
你会看到错误:
Ready False Wed, 30 Oct 2019 09:55:09 +0000 Wed, 30 Oct 2019 09:50:03 +0000 KubeletNotReady runtime network not ready: Ne
tworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
It means that you have to install one of CNIs.这意味着您必须安装其中一个 CNI。 List of them can be found here .可以在此处找到它们的列表。
EDIT编辑
Also one thing comes to my mind.我还想到一件事。
Sometimes when you turned off and on VM you need to restart kubelet and docker service.有时,当您关闭并打开 VM 时,您需要重新启动 kubelet 和 docker 服务。 You can do it by using您可以使用
$ service docker restart
$ systemctl restart kubelet
Hope it helps.希望能帮助到你。
Looks like kubeconfig file is missing.. Did you copy admin.conf file to ~/.kube/config?看起来 kubeconfig 文件丢失了。您是否将 admin.conf 文件复制到 ~/.kube/config?
Verify if there are any proxies set like "http_proxy" or "https_proxy", mostly we set it as environment variables.验证是否有任何代理设置,如“http_proxy”或“https_proxy”,大多数情况下我们将其设置为环境变量。 If yes, then remove the proxies and it should work for you.如果是,则删除代理,它应该对您有用。
I did the following 2 steps.我做了以下两个步骤。 The kubectl works now. kubectl 现在可以工作了。
$ service docker restart
$ systemctl restart kubelet
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.