The connection to the server ip:6443 was refused - did you specify the right host or port

简介: The connection to the server ip:6443 was refused - did you specify the right host or port

文章目录

解决方法1:

export KUBECONFIG=/etc/kubernetes/admin.conf
export $HOME/.kube/config

解决方法2:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf HOME/.kube/config sudo chown (id -u):$(id -g) $HOME/.kube/config
Alternatively you can also export KUBECONFIG variable like this:
export KUBECONFIG=$HOME/.kube/config

解决方法3:

#!/bin/bash
swapoff -a
systemctl start kubelet
docker start (docker ps -a -q)
docker start (docker ps -a -q)

解决方法4:

sudo systemctl status firewalld #redhat centos
sudo systemctl stop firewalld #redhat, centos
sudo ufw status verbose #ubuntu
sudo ufw disable #ubuntu

解决方法5:

  • master: 192.168.211.40
  • node1: 192.168.211.41
  • node2: 192.168.211.42

master

$ kubeadm reset
$ kubeadm init  --pod-network-cidr=172.22.0.0/16 --apiserver-advertise-address=192.168.211.40 --kubernetes-version=v1.20.1
..........
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.211.40:6443 --token s7apx1.mlxn2jkid6n99fr0 \
    --discovery-token-ca-cert-hash sha256:2fa9da39110d02efaf4f8781aa50dd25cce9be524618dc7ab91a53e81c5c22f8 
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

node1

$ kubeadm reset
$ kubeadm join 192.168.211.40:6443 --token s7apx1.mlxn2jkid6n99fr0 \
    --discovery-token-ca-cert-hash sha256:2fa9da39110d02efaf4f8781aa50dd25cce9be524618dc7ab91a53e81c5c22f8 

master

$ kubectl get nodes
NAME     STATUS   ROLES    AGE     VERSION
master   Ready    master   5m18s   v1.18.6
node1    Ready    <none>   81s     v1.18.6
node2    Ready    <none>   43s     v1.18.6
$ scp /root/.kube/config root@192.168.211.41:/root/.kube/config
$ scp /root/.kube/config root@192.168.211.42:/root/.kube/config
$ root@master:~# kubectl get pods -A
NAMESPACE     NAME                             READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-2xmnt         0/1     Pending   0          21m
kube-system   coredns-66bff467f8-ghj2s         0/1     Pending   0          21m
kube-system   etcd-master                      1/1     Running   0          22m
kube-system   kube-apiserver-master            1/1     Running   0          22m
kube-system   kube-controller-manager-master   1/1     Running   0          22m
kube-system   kube-proxy-dh46z                 1/1     Running   0          7m35s
kube-system   kube-proxy-jq6cb                 1/1     Running   0          21m
kube-system   kube-proxy-z6prp                 1/1     Running   0          9m14s
kube-system   kube-scheduler-master            1/1     Running   0          22m
$ kubectl apply -f https://docs.projectcalico.org/v3.10/manifests/calico.yaml
configmap/calico-config created
customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamblocks.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/blockaffinities.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamhandles.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamconfigs.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networksets.crd.projectcalico.org created
clusterrole.rbac.authorization.k8s.io/calico-kube-controllers created
clusterrolebinding.rbac.authorization.k8s.io/calico-kube-controllers created
clusterrole.rbac.authorization.k8s.io/calico-node created
clusterrolebinding.rbac.authorization.k8s.io/calico-node created
daemonset.apps/calico-node created
serviceaccount/calico-node created
deployment.apps/calico-kube-controllers created
serviceaccount/calico-kube-controllers created

参考资料:

https://discuss.kubernetes.io/t/the-connection-to-the-server-host-6443-was-refused-did-you-specify-the-right-host-or-port/552/45



相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
18天前
|
网络协议 Ubuntu Linux
解决ssh: connect to host IP port 22: Connection timed out报错(scp传文件指定端口)
解决 `ssh: connect to host IP port 22: Connection timed out` 报错涉及检查 SSH 服务状态、防火墙配置、网络连通性和主机名解析等多个方面。通过逐步排查上述问题,并在 `scp` 命令中正确指定端口,可以有效解决连接超时的问题,确保文件传输的顺利进行。希望本文提供的解决方案能帮助您快速定位并解决该错误。
52 3
|
4月前
|
网络协议 Shell 网络安全
ssh: connect to host github.com port 22: Connection refused
本文讨论了在使用Git命令操作GitHub时遇到的"ssh: connect to host github.com port 22: Connection refused"错误,分析了可能的原因,并提供了使用443端口或https协议作为解决方案,最终确定问题是由于DNS解析错误导致,通过修改hosts文件解决。
ssh: connect to host github.com port 22: Connection refused
|
5月前
|
网络协议 关系型数据库 MySQL
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
|
5月前
|
应用服务中间件 nginx Docker
connect() failed (113: No route to host) while connecting to upstream
connect() failed (113: No route to host) while connecting to upstream
184 0
|
6月前
|
网络安全
阿里云Could not connect to SITP host: smtp.163.com,port: 25;
阿里云Could not connect to SITP host: smtp.163.com,port: 25;
247 1
|
7月前
|
分布式计算 Hadoop 网络安全
[m1pro ] ssh: connect to host localhost port 22: Connection refused
[m1pro ] ssh: connect to host localhost port 22: Connection refused
|
Java 应用服务中间件 PHP
Nginx——*5 connect() failed (111: Connection refused) while connecting to upstream
Nginx——*5 connect() failed (111: Connection refused) while connecting to upstream
719 0
Nginx——*5 connect() failed (111: Connection refused) while connecting to upstream
【MySQL8】1130 - Host *** is not allowed to connect to this MySOL server
【MySQL8】1130 - Host *** is not allowed to connect to this MySOL server
|
Kubernetes 网络协议 容器
kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host
kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host
1060 0
|
Linux 网络安全
ssh: connect to host 10.13.69.163 port 22: No route to host
ssh: connect to host 10.13.69.163 port 22: No route to host