rke2集群安装完成之后使用kubectl反应很慢

从头开始检查

检查kubectl请求

root@rke2-3:~# kubectl get nodes -v 9
I0317 12:03:12.948874   50681 loader.go:372] Config loaded from file:  /root/.kube/config
I0317 12:03:12.966771   50681 round_trippers.go:435] curl -v -XGET  -H "User-Agent: kubectl/v1.22.17+rke2r1 (linux/amd64) kubernetes/a7736ea" -H "Accept: application/json, */*" 'https://127.0.0.1:6443/apis/metrics.k8s.io/v1beta1?timeout=32s'
I0317 12:03:17.976244   50681 round_trippers.go:454] GET https://127.0.0.1:6443/apis/metrics.k8s.io/v1beta1?timeout=32s 503 Service Unavailable in 5009 milliseconds
I0317 12:03:17.976302   50681 round_trippers.go:460] Response Headers:
I0317 12:03:17.976310   50681 round_trippers.go:463]     Date: Fri, 17 Mar 2023 04:03:17 GMT
I0317 12:03:17.976314   50681 round_trippers.go:463]     Audit-Id: 6161f664-ef9b-4c43-bc8a-7a9bc4aadc4d
I0317 12:03:17.976318   50681 round_trippers.go:463]     Cache-Control: no-cache, private
I0317 12:03:17.976322   50681 round_trippers.go:463]     Content-Type: text/plain; charset=utf-8
I0317 12:03:17.976326   50681 round_trippers.go:463]     X-Content-Type-Options: nosniff
I0317 12:03:17.976330   50681 round_trippers.go:463]     X-Kubernetes-Pf-Flowschema-Uid: 18ac6688-4bae-4287-bb86-d3e59b300a3b
I0317 12:03:17.976334   50681 round_trippers.go:463]     X-Kubernetes-Pf-Prioritylevel-Uid: 8030cae1-7f3d-431a-90c4-09f0ba76b7aa
I0317 12:03:17.976338   50681 round_trippers.go:463]     Content-Length: 68
I0317 12:03:17.979957   50681 request.go:1197] Response Body: error trying to reach service: dial tcp 10.42.0.3:8443: i/o timeout
I0317 12:03:17.983359   50681 request.go:1388] body was not decodable (unable to check for Status): yaml: mapping values are not allowed in this context
I0317 12:03:17.983405   50681 cached_discovery.go:78] skipped caching discovery info due to the server is currently unable to handle the request
I0317 12:03:17.984416   50681 round_trippers.go:435] curl -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.22.17+rke2r1 (linux/amd64) kubernetes/a7736ea" 'https://127.0.0.1:6443/apis/metrics.k8s.io/v1beta1?timeout=32s'

发现超时在这一个请求 https://127.0.0.1:6443/apis/metrics.k8s.io/v1beta1?timeout=32s 503 Service Unavailable in 5009 milliseconds

检查.kube/config

root@rke2-1:~/.kube# cat config 
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: xxx
    server: https://127.0.0.1:6443
  name: default
contexts:
- context:
    cluster: default
    user: default
  name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
  user:
    client-certificate-data: xxx
    client-key-data: xxx

在除了第一个server节点上运行kubectl都很卡,检查kubectl的配置文件,发现请求的server是127.0.0.1

于是修改为负载均衡ip或者域名即可解决问题

load_balancer_addr=rancher2.ent.top
sed -i.bak "s/127.0.0.1:6443/${load_balancer_addr}:6443/" /etc/rancher/rke2/rke2.yaml
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值