Skip to content

Commit b0d98bd

Browse files
Disable zone filter, add flag to set zones manually
This the only sane way to fix UnsupportedAvailabilityZoneException, espcially because it turns out that this is somehow different in every AWS account (at least that what seems to be the case from the docs. > You may receive an error that one of the Availability Zones in your > request does not have sufficient capacity to create an Amazon EKS > cluster. If this happens, the error output contains the Availability > Zones that can support a new cluster. Retry creating your cluster > with at least two subnets that are located in the supported > Availability Zones for your account. In the future we may try parsing the error message and retrying automatically, but it doesn't seem feasible right now as we would need to improve some of the internals and provide stack update functionality.
1 parent 6a1179e commit b0d98bd

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ To use a pre-existing EC2 key pair in `us-east-1` region, you can specify key pa
130130
eksctl create cluster --ssh-public-key=my_kubernetes_key --region=us-east-1
131131
```
132132

133+
> NOTE: In `us-east-1` you are likely to get `UnsupportedAvailabilityZoneException`. If you do, copy the suggested zones and pass `--zones` flag, e.g. `eksctl create cluster --region=us-east-1 --zones=us-east-1a,us-east-1b,us-east-1d`. This may occur in other regions, but less likely. You shouldn't need to use `--zone` flag otherwise.
134+
133135
To delete a cluster, run:
134136

135137
```

cmd/eksctl/create.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var (
4242
kubeconfigPath string
4343
autoKubeconfigPath bool
4444
setContext bool
45+
availabilityZones []string
4546
)
4647

4748
func createClusterCmd() *cobra.Command {
@@ -74,6 +75,8 @@ func createClusterCmd() *cobra.Command {
7475
fs.IntVarP(&cfg.MinNodes, "nodes-min", "m", 0, "minimum nodes in ASG")
7576
fs.IntVarP(&cfg.MaxNodes, "nodes-max", "M", 0, "maximum nodes in ASG")
7677

78+
fs.StringSliceVar(&availabilityZones, "zones", nil, "(auto-select if unspecified)")
79+
7780
fs.StringVar(&cfg.SSHPublicKeyPath, "ssh-public-key", DEFAULT_SSH_PUBLIC_KEY, "SSH public key to use for nodes (import from local path, or use existing EC2 key pair)")
7881

7982
fs.BoolVar(&writeKubeconfig, "write-kubeconfig", true, "toggle writing of kubeconfig")
@@ -117,7 +120,7 @@ func doCreateCluster(cfg *eks.ClusterConfig, name string) error {
117120
return fmt.Errorf("--region=%s is not supported only %s and %s are supported", cfg.Region, EKS_REGION_US_WEST_2, EKS_REGION_US_EAST_1)
118121
}
119122

120-
if err := ctl.SetAvailabilityZones(); err != nil {
123+
if err := ctl.SetAvailabilityZones(availabilityZones); err != nil {
121124
return err
122125
}
123126

pkg/az/az.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ type AvailabilityZoneSelector struct {
8484
func NewSelectorWithDefaults(ec2api ec2iface.EC2API) *AvailabilityZoneSelector {
8585
avoidZones := map[string]bool{
8686
// well-known over-populated zones
87-
"us-east-1a": true,
88-
"us-east-1b": true,
87+
// "us-east-1a": true,
88+
// "us-east-1b": true,
8989
}
9090

9191
return &AvailabilityZoneSelector{

pkg/az/az_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ func createAvailabilityZone(region string, state string, zone string) *ec2.Avail
232232

233233
func avoidedZones(initialStatus string) []*ec2.AvailabilityZone {
234234
return []*ec2.AvailabilityZone{
235-
createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1a"),
236-
createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1b"),
235+
// createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1a"),
236+
// createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1b"),
237237
}
238238
}
239239

pkg/eks/api.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,23 @@ func (c *ClusterProvider) CheckAuth() error {
180180
return nil
181181
}
182182

183-
func (c *ClusterProvider) SetAvailabilityZones() error {
184-
logger.Debug("determining availability zones")
185-
azSelector := az.NewSelectorWithDefaults(c.Provider.EC2())
186-
zones, err := azSelector.SelectZones(c.Spec.Region)
187-
if err != nil {
188-
return errors.Wrap(err, "getting availability zones")
189-
}
183+
func (c *ClusterProvider) SetAvailabilityZones(given []string) error {
184+
if len(given) == 0 {
185+
logger.Debug("determining availability zones")
186+
azSelector := az.NewSelectorWithDefaults(c.Provider.EC2())
187+
zones, err := azSelector.SelectZones(c.Spec.Region)
188+
if err != nil {
189+
return errors.Wrap(err, "getting availability zones")
190+
}
190191

191-
logger.Info("setting availability zones to %v", zones)
192-
c.Status.availabilityZones = zones
192+
logger.Info("setting availability zones to %v", zones)
193+
c.Status.availabilityZones = zones
194+
return nil
195+
}
196+
if len(given) < az.DefaultRequiredAvailabilityZones {
197+
return fmt.Errorf("only %d zones specified %v, %d are required (can be non-unque)", len(given), given, az.DefaultRequiredAvailabilityZones)
198+
}
199+
c.Status.availabilityZones = given
193200
return nil
194201
}
195202

0 commit comments

Comments
 (0)