<p>I have spot instance nodes in Azure Kubernetes Cluster. I want to simulate the eviction of a node so as to debug my code but not able to. All I could find in azure docs is we can simulate eviction for a single spot instance, using the following:</p>
<pre><code>az vm simulate-eviction --resource-group test-eastus --name test-vm-26
</code></pre>
<p>However, I need to simulate the eviction of a spot node pool or a spot node in an AKS cluster.</p>

bor
<p>For simulating evictions, there is no AKS REST API or Azure CLI command because evictions of the underlying infrastructure is not handled by AKS RP.
Only during creation of the AKS cluster the AKS RP can set eviction Policy on the underlying infrastructure by instructing the Azure Compute RP to do so.
Instead to simulate the eviction of node infrastructure, the customer can use az vmsss simulate-eviction command or the corresponding REST API.</p>
<p><strong>az vmss simulate-eviction</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>az vmss simulate-eviction --instance-id
                          --name
                          --resource-group
                          [--subscription]</code></pre>
</div>
</div>
</p>
<p>Reference Documents:</p>
<ul>
<li><a href="https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest#az_vmss_simulate_eviction" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest#az_vmss_simulate_eviction</a></li>
<li><a href="https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-scale-set-vms/simulate-eviction" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-scale-set-vms/simulate-eviction</a></li>
</ul>
<hr />
<hr />
<p>Use the following commands to get the name of the vmss with nodepool:</p>
<p>1.</p>
<pre><code> az aks nodepool list -g $ClusterRG --cluster-name $ClusterName -o
    table
</code></pre>
<p>Get the desired node pool name from the output</p>
<p>2.</p>
<pre><code> CLUSTER_RESOURCE_GROUP=$(az aks show  –resource-group YOUR_Resource_Group --name YOUR_AKS_Cluster --query
nodeResourceGroup -o tsv)
</code></pre>
<ol start="3">
<li></li>
</ol>
<pre><code>az vmss list -g $CLUSTER_RESOURCE_GROUP --query &quot;[?tags.poolName ==    '&lt;NODE_POOL_NAME&gt;'].{VMSS_Name:name}&quot; -o tsv
</code></pre>
<p>References:</p>
<ol>
<li><a href="https://louisshih.gitbooks.io/kubernetes/content/chapter1.html" rel="nofollow noreferrer">https://louisshih.gitbooks.io/kubernetes/content/chapter1.html</a></li>
<li><a href="https://ystatit.medium.com/azure-ssh-into-aks-nodes-471c07ad91ef" rel="nofollow noreferrer">https://ystatit.medium.com/azure-ssh-into-aks-nodes-471c07ad91ef</a></li>
<li><a href="https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest#az_vmss_list_instances" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest#az_vmss_list_instances</a></li>
</ol>
<p>(you may create vmss if you dont have it configured. Refer :<a href="https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/quick-create-portal" rel="nofollow noreferrer">create a VMSS</a>)</p>
