kubeadm init之后kubectl get nodes

本文介绍了解决在使用kubectl命令时遇到的连接错误问题的方法。通过执行特定的配置文件复制和权限更改步骤,确保kubectl能够正确地与集群进行通信。此外,还提供了处理由于缺少内核模块而导致的问题的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

kubeadm init之后kubectl get nodes  提示“The connection to the server localhost:8080 was refused - did you specify the right host or port?”

did you run below commands after kubeadm init

To start using your cluster, you need to run (as a regular user):

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf (关键一条)

 

----------------------------------------------------

 

[root@192.168.127.132 yum.repos.d]#kubeadm join 192.168.127.134:6443 --token tzb8fz.q3bqdwxmlht7gebj --discovery-token-ca-cert-hash sha256:59215d1229bd7cab2bc44872a34feba2055d7e7ed62b518415343001d3723e38
[preflight] running pre-flight checks
    [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_rr ip_vs_wrr ip_vs_sh ip_vs] or no builtin kernel ipvs support: map[ip_vs_sh:{} nf_conntrack_ipv4:{} ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{}]
you can solve this problem with following methods:
 1. Run 'modprobe -- ' to load missing kernel modules;
2. Provide the missing builtin kernel ipvs support

    [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
I0802 01:56:29.715075    1849 kernel_validator.go:81] Validating kernel version
I0802 01:56:29.715268    1849 kernel_validator.go:96] Validating kernel config
[discovery] Trying to connect to API Server "192.168.127.134:6443"
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.127.134:6443"
[discovery] Requesting info from "https://192.168.127.134:6443" again to validate TLS against the pinned public key
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.127.134:6443"
[discovery] Successfully established connection with API Server "192.168.127.134:6443"
[kubelet] Downloading configuration for the kubelet from the "kubelet-config-1.11" ConfigMap in the kube-system namespace
[kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[preflight] Activating the kubelet service
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "192.168.127.132" as an annotation

This node has joined the cluster:
* Certificate signing request was sent to master and a response
  was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the master to see this node join the cluster.
[root@192.168.127.132 yum.repos.d]#modprobe ip_vs_rr
[root@192.168.127.132 yum.repos.d]#modprobe ip_vs_wrr
[root@192.168.127.132 yum.repos.d]#modprobe ip_vs_sh
[root@192.168.127.132 yum.repos.d]#modprobe ip_vs

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值