在AKS节点池中按比例重启虚拟机

问题描述

我有一个带有节点池的kubernetes集群,作为Chaos Engineering Initiative的一部分,我需要重新启动VM。使用Azure资源图是否有相同的代码

解决方法

当AKS节点是比例集时。然后,您需要找到节点资源组,规模集名称和要重新启动的实例ID。然后重新启动实例。以下是CLI命令:

# get the AKS node resource group name
az aks show -g groupName -n aksName --query nodeResourceGroup

# get the scale set info and all the instance id
az vmss list -g nodeGroupName --query [].name
az vmss list-instances -g nodeGroupName -n vmssName -o table

# restart the instance with the instance Id
az vmss restart -g nodeGroupName -n vmssName --instance-ids n

如果在Azure门户中进行此操作,则步骤相同,但更容易实现。

,

Chaos工具包已经具有用于从scaleset提取vm的代码。可以在https://github.com/chaostoolkit-incubator/chaostoolkit-azure/blob/master/chaosazure/vmss/fetcher.py处检查代码。