Skip to content

Disable zone filter, add flag to set zones manually #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ To use a pre-existing EC2 key pair in `us-east-1` region, you can specify key pa
eksctl create cluster --ssh-public-key=my_kubernetes_key --region=us-east-1
```

> 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.

To delete a cluster, run:

```
Expand Down
5 changes: 4 additions & 1 deletion cmd/eksctl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
kubeconfigPath string
autoKubeconfigPath bool
setContext bool
availabilityZones []string
)

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

fs.StringSliceVar(&availabilityZones, "zones", nil, "(auto-select if unspecified)")

This comment was marked as abuse.


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)")

fs.BoolVar(&writeKubeconfig, "write-kubeconfig", true, "toggle writing of kubeconfig")
Expand Down Expand Up @@ -117,7 +120,7 @@ func doCreateCluster(cfg *eks.ClusterConfig, name string) error {
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)
}

if err := ctl.SetAvailabilityZones(); err != nil {
if err := ctl.SetAvailabilityZones(availabilityZones); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/az/az.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ type AvailabilityZoneSelector struct {
func NewSelectorWithDefaults(ec2api ec2iface.EC2API) *AvailabilityZoneSelector {
avoidZones := map[string]bool{
// well-known over-populated zones
"us-east-1a": true,
"us-east-1b": true,
// "us-east-1a": true,

This comment was marked as abuse.

This comment was marked as abuse.

// "us-east-1b": true,
}

return &AvailabilityZoneSelector{
Expand Down
4 changes: 2 additions & 2 deletions pkg/az/az_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ func createAvailabilityZone(region string, state string, zone string) *ec2.Avail

func avoidedZones(initialStatus string) []*ec2.AvailabilityZone {
return []*ec2.AvailabilityZone{
createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1a"),
createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1b"),
// createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1a"),
// createAvailabilityZone("US East (N. Virginia)", initialStatus, "us-east-1b"),
}
}

Expand Down
25 changes: 16 additions & 9 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,23 @@ func (c *ClusterProvider) CheckAuth() error {
return nil
}

func (c *ClusterProvider) SetAvailabilityZones() error {
logger.Debug("determining availability zones")
azSelector := az.NewSelectorWithDefaults(c.Provider.EC2())
zones, err := azSelector.SelectZones(c.Spec.Region)
if err != nil {
return errors.Wrap(err, "getting availability zones")
}
func (c *ClusterProvider) SetAvailabilityZones(given []string) error {
if len(given) == 0 {
logger.Debug("determining availability zones")
azSelector := az.NewSelectorWithDefaults(c.Provider.EC2())
zones, err := azSelector.SelectZones(c.Spec.Region)
if err != nil {
return errors.Wrap(err, "getting availability zones")
}

logger.Info("setting availability zones to %v", zones)
c.Status.availabilityZones = zones
logger.Info("setting availability zones to %v", zones)
c.Status.availabilityZones = zones
return nil
}
if len(given) < az.DefaultRequiredAvailabilityZones {
return fmt.Errorf("only %d zones specified %v, %d are required (can be non-unque)", len(given), given, az.DefaultRequiredAvailabilityZones)
}
c.Status.availabilityZones = given
return nil
}

Expand Down