使用 kubectl 删除节点后,Azure Ui 显示错误数量的节点
Azure Ui shows wrong amount of nodes after deleting nodes with kubectl
我手动删除了 Kubernetes 集群的两个节点,首先调用“kubectl drain”,然后为每个节点调用“kubectl delete”。虽然集群似乎没有问题地工作,但 Azure UI 向我显示的节点比我使用“kubectl get nodes”时看到的多了两个节点。因此,当我将 Kubernetes 配置为在 Azure UI 中有 9 个节点时,如果我使用 kubectl 查看,则只有 7 个节点。向上或向下扩展都不能解决问题,因为 Azure 总是被两个节点关闭。
我怎么解决这个问题?有什么方法可以通知 Azure 节点已被删除?
要想解决问题,需要对k8s集群有更深入的了解。
当您使用命令kubectl delete
从代理池中删除节点时,这意味着代理池将无法控制该节点。但这并不意味着你真的删除了机器。所以你可以在 Azure 门户中发现机器的数量没有变化。这就是你发现的真相。
How can I solve this problem? Is there a way I can notify Azure that a
node has been deleted?
这里有两个问题。对于第一种,可以这样表达:
How to restore the node that deleted before to the agent pool?
解决起来很简单。您只需要重新启动该节点中的 kubelet
服务即可。比如你使用VMSS作为AKS的代理池,节点实例id为4,那么你可以这样:
az vmss run-command invoke --resource-group group_name --name vmss_name --instance-id 4 --command-id RunShellScript --scripts "service kubelet restart"
对于第二个,您只能使用Azure 命令让Azure 知道更新。这意味着您可以扩展代理池,例如,使用 Azure CLI 命令:
az aks nodepool --resource-group group_name --name agentpool_name --cluster-name cluster_name --node-count 2
我手动删除了 Kubernetes 集群的两个节点,首先调用“kubectl drain”,然后为每个节点调用“kubectl delete”。虽然集群似乎没有问题地工作,但 Azure UI 向我显示的节点比我使用“kubectl get nodes”时看到的多了两个节点。因此,当我将 Kubernetes 配置为在 Azure UI 中有 9 个节点时,如果我使用 kubectl 查看,则只有 7 个节点。向上或向下扩展都不能解决问题,因为 Azure 总是被两个节点关闭。 我怎么解决这个问题?有什么方法可以通知 Azure 节点已被删除?
要想解决问题,需要对k8s集群有更深入的了解。
当您使用命令kubectl delete
从代理池中删除节点时,这意味着代理池将无法控制该节点。但这并不意味着你真的删除了机器。所以你可以在 Azure 门户中发现机器的数量没有变化。这就是你发现的真相。
How can I solve this problem? Is there a way I can notify Azure that a node has been deleted?
这里有两个问题。对于第一种,可以这样表达:
How to restore the node that deleted before to the agent pool?
解决起来很简单。您只需要重新启动该节点中的 kubelet
服务即可。比如你使用VMSS作为AKS的代理池,节点实例id为4,那么你可以这样:
az vmss run-command invoke --resource-group group_name --name vmss_name --instance-id 4 --command-id RunShellScript --scripts "service kubelet restart"
对于第二个,您只能使用Azure 命令让Azure 知道更新。这意味着您可以扩展代理池,例如,使用 Azure CLI 命令:
az aks nodepool --resource-group group_name --name agentpool_name --cluster-name cluster_name --node-count 2