3

I have a kubernetes cluster with node pools and as a part of Chaos Engineering Initiative,I need to restart the VM. Is there any code for the same using azure resource graph?

Batman22
  • 376
  • 4
  • 25

3 Answers3

6

When the AKS nodes is a scale set. Then you need to find the node resource group, the scale set name, and the instance-id that you want to restart. And then restart the instance. Here are the CLI commands:

# 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

If you do it in the Azure portal, the same steps but it's easier to achieve.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
1

You can install Gremlin on your AKS cluster. Here is an in-depth tutorial that I wrote: https://www.gremlin.com/community/tutorials/how-to-install-and-use-gremlin-with-kubernetes/

When practicing Chaos Engineering on a kubernetes cluster it's important to control the blast radius of your attacks - e.g. how many VMs will you restart? Do you want to restart the whole VM or just 1 or more pods on the VM.

0

Chaos toolkit already has the code for fetching vms from scaleset. The code can be checked at https://github.com/chaostoolkit-incubator/chaostoolkit-azure/blob/master/chaosazure/vmss/fetcher.py.

Batman22
  • 376
  • 4
  • 25