Check and docs

This commit is contained in:
Rodrigo Menezes 2017-11-26 20:37:16 -08:00
parent 863d080011
commit f908dcb3bf
3 changed files with 49 additions and 5 deletions

View File

@ -76,6 +76,36 @@ probably remove that tag to indicate that the resources are not owned by that cl
deleting the cluster won't try to delete the VPC. (Deleting the VPC won't succeed anyway, because it's in use,
but it's better to avoid the later confusion!)
### VPC with multiple CIDRs
AWS now allows you to add more CIDRs to a VPC, the param `AdditionalNetworkCIDRs` allows you to specify any additional CIDRs added to the VPC.
```
metadata:
creationTimestamp: "2016-06-27T14:23:34Z"
name: ${CLUSTER_NAME}
spec:
cloudProvider: aws
networkCIDR: 10.1.0.0/16
AdditionalNetworkCIDRs:
- 10.2.0.0/16
networkID: vpc-00aa5577
subnets:
- cidr: 10.1.0.0/19
name: us-east-1b
type: Public
zone: us-east-1b
id: subnet-1234567
- cidr: 10.2.0.0/19
name: us-east-1b
type: Public
zone: us-east-1b
id: subnet-1234568
```
## Advanced Options for Creating Clusters in Existing VPCs
### Shared Subnets

View File

@ -496,7 +496,7 @@ func ValidateCluster(c *kops.Cluster, strict bool) *field.Error {
return nil
}
// validateEtcdClusterSpec is responsible for validating the etcd cluster spec
// validateSubnetCIDR is responsible for validating subnets are part of the CIRDs assigned to the cluster.
func validateSubnetCIDR(networkCIDR *net.IPNet, additionalNetworkCIDRs []*net.IPNet, subnetCIDR *net.IPNet) bool {
if isSubnet(networkCIDR, subnetCIDR) {
return true

View File

@ -36,6 +36,7 @@ type VPC struct {
ID *string
CIDR *string
AdditionalCIDR *[]string
EnableDNSHostnames *bool
EnableDNSSupport *bool
@ -75,10 +76,11 @@ func (e *VPC) Find(c *fi.Context) (*VPC, error) {
}
vpc := response.Vpcs[0]
actual := &VPC{
ID: vpc.VpcId,
CIDR: vpc.CidrBlock,
Name: findNameTag(vpc.Tags),
Tags: intersectTags(vpc.Tags, e.Tags),
ID: vpc.VpcId,
CIDR: vpc.CidrBlock,
AdditionalCIDR: getAdditionalCIDR(vpc.CidrBlock, vpc.CidrBlockAssociationSet),
Name: findNameTag(vpc.Tags),
Tags: intersectTags(vpc.Tags, e.Tags),
}
glog.V(4).Infof("found matching VPC %v", actual)
@ -273,3 +275,15 @@ func (e *VPC) CloudformationLink() *cloudformation.Literal {
return cloudformation.Ref("AWS::EC2::VPC", *e.Name)
}
func getAdditionalCIDR(CIDR *string, additionalCIDRSet []*ec2.VpcCidrBlockAssociation) *[]string {
var additionalCIDRs []string
for _, CIDRSet := range additionalCIDRSet {
if *CIDRSet.CidrBlock != *CIDR {
additionalCIDRs = append(additionalCIDRs, *CIDRSet.CidrBlock)
}
}
return &additionalCIDRs
}