我试图在集群中每个节点使用500+ pod。我已经将maxPods设置为1k,并且从节点信息中可以看到这是成功的。
然而,法兰绒不允许我使用超过254,因为它为pod使用24个子网,范围在x.1到x.255。
有办法做到这一点吗?我尝试将pod-network-cidr增加到8,并且还配置了法兰绒net-conf,如下所示
{
"Network": "10.0.0.0/8",
"SubnetLen": 16,
"SubnetMin": "10.10.0.0",
"SubnetMax": "10.99.0.0",
"Backend": {
"Type": "host-gw"
}
}
但这似乎并不影响我集群。
下面是挂起的pod的事件输出
rpc error: code = Unknown desc = failed to set up sandbox
container "f5721f2419ad98fc8f26ad42f3f142a5733db38fefacc6d6f75cc38bd890233a" network for pod "test-deployment-f69647ffc-2bgb6": networkPlugin cni failed to set up
pod "test-deployment-f69647ffc-2bgb6_default" network: failed to allocate for range 0: no IP addresses available in range set: 10.0.0.1-10.0.0.254
Warning FailedCreatePodSandBox 8m18s (x80 over 30m) kubelet (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "7045913eb55f3fbae10fe42de5fe29de73848e0cf005e96fa61286cdb127bc7d" network for pod "test-deployment-f69647ffc-2bgb6": net
workPlugin cni failed to set up pod "test-deployment-f69647ffc-2bgb6_default" network: failed to allocate for range 0: no IP addresses available in range set: 10.0.0.1-10.0.0.254
通过更改kube-controller-manager的node-cidr-mask-size来解决。
k8:
将--node-cidr-mask-size 16
传递给kube-controller-manager,将--pod-network-cidr=10.0.0.0/8
传递给kubeadm。编辑kube-flannel。yml, net-conf。
k3:
export INSTALL_K3S_EXEC="--flannel-conf "<path-to-your-flannel-configuration>" --cluster-cidr "10.0.0.0/8" --kube-controller-manager-arg "node-cidr-mask-size=16"""
- 按照下面的示例编辑您的法兰绒配置文件,然后像往常一样安装k3s。
法兰绒配置示例:
{
"Network": "10.0.0.0/8",
"Backend": {
"Type": "vxlan"
}
}