Skip to content
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

Add AZ selector logic #124

Merged
merged 4 commits into from
Jul 20, 2018
Merged

Add AZ selector logic #124

merged 4 commits into from
Jul 20, 2018

Conversation

errordeveloper
Copy link
Contributor

Fixes #118 and #101.

@errordeveloper errordeveloper changed the title Add AZ selector logic WIP: Add AZ selector logic Jul 18, 2018
@errordeveloper
Copy link
Contributor Author

errordeveloper commented Jul 18, 2018

We have test and they are failing, isn't that nice? 😺 📣 😻

@errordeveloper
Copy link
Contributor Author

errordeveloper commented Jul 18, 2018

@richardcase tests LGTM, thank you!

@richardcase
Copy link
Contributor

richardcase commented Jul 19, 2018

When trying to create a cluster with this i get the following error:

2018-07-19T14:17:38+01:00 [✖]  creating CloudFormation stack "EKS-richtest23-VPC": ValidationError: Parameters: [AvailabilityZones] do not exist in the template
        status code: 400, request id: 1b9221c4-8b56-11e8-88ec-dfaeea4eb12a

Looking at the debug output i can see the availability zones are passed in as a parameter but not sure whats going wrong:

2018-07-19T14:17:37+01:00 [▶]  input = {
  Parameters: [{
      ParameterKey: "AvailabilityZones",
      ParameterValue: "us-west-2a,us-west-2c,us-west-2b"
    }],
  StackName: "EKS-richtest23-VPC",
  Tags: [{
      Key: "eksctl.cluster.k8s.io/v1alpha1/cluster-name",
      Value: "richtest23"
    }],
  TemplateBody: "---\nAWSTemplateFormatVersion: '2010-09-09'\nDescription: 'Amazon EKS Sample VPC'\n\nParameters:\n\n  VpcBlock:\n    Type: String\n    Default: 192.168.0.0/16\n    Description: The CIDR range for the VPC. This should be a valid private (RFC 1918) CIDR range.\n\n  Subnet01Block:\n    Type: String\n    Default: 192.168.64.0/18\n    Description: CidrBlock for subnet 01 within the VPC\n\n  Subnet02Block:\n    Type: String\n    Default: 192.168.128.0/18\n    Description: CidrBlock for subnet 02 within the VPC\n\n  Subnet03Block:\n    Type: String\n    Default: 192.168.192.0/18\n    Description: CidrBlock for subnet 03 within the VPC\n\nMetadata:\n  AWS::CloudFormation::Interface:\n    ParameterGroups:\n      -\n        Label:\n          default: \"Worker Network Configuration\"\n        Parameters:\n          - VpcBlock\n          - Subnet01Block\n          - Subnet02Block\n          - Subnet03Block\n\nResources:\n  VPC:\n    Type: AWS::EC2::VPC\n    Properties:\n      CidrBlock:  !Ref VpcBlock\n      EnableDnsSupport: true\n      EnableDnsHostnames: true\n      Tags:\n      - Key: Name\n        Value: !Sub '${AWS::StackName}-VPC'\n\n  InternetGateway:\n    Type: \"AWS::EC2::InternetGateway\"\n\n  VPCGatewayAttachment:\n    Type: \"AWS::EC2::VPCGatewayAttachment\"\n    Properties:\n      InternetGatewayId: !Ref InternetGateway\n      VpcId: !Ref VPC\n\n  RouteTable:\n    Type: AWS::EC2::RouteTable\n    Properties:\n      VpcId: !Ref VPC\n      Tags:\n      - Key: Name\n        Value: Public Subnets\n      - Key: Network\n        Value: Public\n\n  Route:\n    DependsOn: VPCGatewayAttachment\n    Type: AWS::EC2::Route\n    Properties:\n      RouteTableId: !Ref RouteTable\n      DestinationCidrBlock: 0.0.0.0/0\n      GatewayId: !Ref InternetGateway\n\n  Subnet01:\n    Type: AWS::EC2::Subnet\n    Metadata:\n      Comment: Subnet 01\n    Properties:\n      AvailabilityZone:\n        Fn::Select:\n        - '0'\n        - Fn::GetAZs:\n            Ref: AWS::Region\n      CidrBlock:\n        Ref: Subnet01Block\n      VpcId:\n        Ref: VPC\n      Tags:\n      - Key: Name\n        Value: !Sub \"${AWS::StackName}-Subnet01\"\n\n  Subnet02:\n    Type: AWS::EC2::Subnet\n    Metadata:\n      Comment: Subnet 02\n    Properties:\n      AvailabilityZone:\n        Fn::Select:\n        - '1'\n        - Fn::GetAZs:\n            Ref: AWS::Region\n      CidrBlock:\n        Ref: Subnet02Block\n      VpcId:\n        Ref: VPC\n      Tags:\n      - Key: Name\n        Value: !Sub \"${AWS::StackName}-Subnet02\"\n\n  Subnet03:\n    Type: AWS::EC2::Subnet\n    Metadata:\n      Comment: Subnet 03\n    Properties:\n      AvailabilityZone:\n        Fn::Select:\n        - '2'\n        - Fn::GetAZs:\n            Ref: AWS::Region\n      CidrBlock:\n        Ref: Subnet03Block\n      VpcId:\n        Ref: VPC\n      Tags:\n      - Key: Name\n        Value: !Sub \"${AWS::StackName}-Subnet03\"\n\n  Subnet01RouteTableAssociation:\n    Type: AWS::EC2::SubnetRouteTableAssociation\n    Properties:\n      SubnetId: !Ref Subnet01\n      RouteTableId: !Ref RouteTable\n\n  Subnet02RouteTableAssociation:\n    Type: AWS::EC2::SubnetRouteTableAssociation\n    Properties:\n      SubnetId: !Ref Subnet02\n      RouteTableId: !Ref RouteTable\n\n  Subnet03RouteTableAssociation:\n    Type: AWS::EC2::SubnetRouteTableAssociation\n    Properties:\n      SubnetId: !Ref Subnet03\n      RouteTableId: !Ref RouteTable\n\n  ControlPlaneSecurityGroup:\n    Type: AWS::EC2::SecurityGroup\n    Properties:\n      GroupDescription: Cluster communication with worker nodes\n      VpcId: !Ref VPC\n\nOutputs:\n\n  SubnetIds:\n    Description: All subnets in the VPC\n    Value: !Join [ \",\", [ !Ref Subnet01, !Ref Subnet02, !Ref Subnet03 ] ]\n\n  SecurityGroups:\n    Description: Security group for the cluster control plane communication with worker nodes\n    Value: !Join [ \",\", [ !Ref ControlPlaneSecurityGroup ] ]\n\n  VpcId:\n    Description: The VPC Id\n    Value: !Ref VPC\n"
}

Not sure how i update the template.

errordeveloper and others added 3 commits July 20, 2018 09:07
Added test around SelectAvailabilityZones. Also changed the function
to return an array of zones instead of mutating ClusterProvider.Status
directly.
Changed the availability zone selection code. Moved into a different
package, added filters to the AWS call and allowed zone selection
to be changed in the future.
@errordeveloper
Copy link
Contributor Author

@richardcase that error was because we forgot to re-genrate biodata for the templates.

@errordeveloper errordeveloper changed the title WIP: Add AZ selector logic Add AZ selector logic Jul 20, 2018
Copy link
Contributor

@richardcase richardcase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I have tested the cluster creation since the template change and it sets the AZs correctly.

@errordeveloper errordeveloper merged commit 57f705b into master Jul 20, 2018
@errordeveloper errordeveloper deleted the add-az-selector-logic branch July 20, 2018 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants