<p>I have the following configuration: </p>

<ul>
<li>installed EKS using terraform module
<a href="https://github.com/terraform-aws-modules/terraform-aws-eks/blob/v4.0.2/examples/basic/main.tf" rel="nofollow noreferrer">https://github.com/terraform-aws-modules/terraform-aws-eks/blob/v4.0.2/examples/basic/main.tf</a></li>
<li>added multi-asg autoscaler
(<a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md" rel="nofollow noreferrer">https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md</a>)</li>
<li>configured working group to run 1 instance per az (in az-1a and az-1b
and pod per instance)</li>
</ul>

<p>When I change POD spec/config I see the next:</p>

<ul>
<li>new instance creation (2 running)

<ul>
<li>2 pods in state running and 1 in pending</li>
</ul></li>
<li>new instance created (3 running)

<ul>
<li>2 pods in state running (age updated for both)</li>
<li>2 pods running on instances in one az</li>
<li>2 running instances in 1 az after scale-down timeout</li>
</ul></li>
</ul>

<p>Is there a proper way to configure autoscaler to create instances/pods in different 2 azs?</p>

malyy
<p>There's two levels to this. The cluster autoscaler instance location and then the kubernetes pod location. </p>

<p>Create an auto scaling group for each availability zone:</p>

<blockquote>
  <ul>
  <li>Cluster autoscaler does not support Auto Scaling Groups which span
  multiple Availability Zones; instead you should use an Auto Scaling
  Group for each Availability Zone and enable the
  <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#im-running-cluster-with-nodes-in-multiple-zones-for-ha-purposes-is-that-supported-by-cluster-autoscaler" rel="nofollow noreferrer"><code>--balance-similar-node-groups</code></a> feature. If you do use a single Auto Scaling Group that spans multiple Availability Zones you will find
  that AWS unexpectedly terminates nodes without them being drained
  because of the <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-benefits.html#arch-AutoScalingMultiAZ" rel="nofollow noreferrer">rebalancing feature</a>.</li>
  </ul>
</blockquote>

<p>Then for kubernetes, use pod <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity" rel="nofollow noreferrer">anti-affinity</a> on the <a href="https://eksworkshop.com/assigning_pods/affinity/" rel="nofollow noreferrer">EKS populated <code>failure-domain.beta.kubernetes.io/zone</code> label</a>.</p>

<p>EBS Volumes don't span availability zones so if you are using persistent volumes you may get stuck with pods in one zone or worst case pods that won't schedule. </p>
