在部署metrics server後,pod啓動成功,但是使用kubectl top node命令時,顯示報錯:
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)
多方查看後,發現在master節點上ping不同metrics server的podIP。兩天的排錯,才發現是使用calico網絡bgp模式後,不同網段之間通信,pod不通
這裏重新生成calico的ippool,使用calico網絡的crosssubnet網絡實現
# 1、備份當前的ippool
calicoctl get ippool -o yaml > pool_bak.yaml
# 2、修改pool_bak.yaml
#----在 natOutgoing: true後面添加一行,關閉該ippool
disabled: true
# 3、應用使生效
calicoctl apply -f pool_bak.yaml
# 4、查看ippool
calicoctl get ippool -o wide
# ***如下顯示
# --NAME CIDR NAT IPIPMODE DISABLED
# default-ipv4-ippool 10.66.0.0/16 true Never true
# ****
# 5、刪除舊的ippool
calicoctl delete pool default-ipv4-ippool
# 6、新建新的ippool
calicoctl create -f -<<EOF
apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
name: new-pool
spec:
cidr: 10.67.0.0/16
ipipMode: CrossSubnet
natOutgoing: true
EOF
# 7、查看新的ippool
# NAME CIDR NAT IPIPMODE DISABLED
# new-pool 10.66.0.0/16 true CrossSubnet false
然後將metrics server等pods重新生成,就可以解決問題啦
BINGO
BINGO
BINGO
BINGO