mirror of https://github.com/kubernetes/kops.git
Tests for create cluster in shared vpc
This commit is contained in:
parent
48d4a7cb1a
commit
afc1b58722
|
@ -60,9 +60,10 @@ func (m *MockEC2) CreateSubnet(request *ec2.CreateSubnetInput) (*ec2.CreateSubne
|
||||||
n := m.subnetNumber
|
n := m.subnetNumber
|
||||||
|
|
||||||
subnet := &ec2.Subnet{
|
subnet := &ec2.Subnet{
|
||||||
SubnetId: s(fmt.Sprintf("subnet-%d", n)),
|
SubnetId: s(fmt.Sprintf("subnet-%d", n)),
|
||||||
VpcId: request.VpcId,
|
VpcId: request.VpcId,
|
||||||
CidrBlock: request.CidrBlock,
|
CidrBlock: request.CidrBlock,
|
||||||
|
AvailabilityZone: request.AvailabilityZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.subnets == nil {
|
if m.subnets == nil {
|
||||||
|
@ -93,7 +94,10 @@ func (m *MockEC2) DescribeSubnets(request *ec2.DescribeSubnetsInput) (*ec2.Descr
|
||||||
for _, filter := range request.Filters {
|
for _, filter := range request.Filters {
|
||||||
match := false
|
match := false
|
||||||
switch *filter.Name {
|
switch *filter.Name {
|
||||||
|
case "vpc-id":
|
||||||
|
if *subnet.main.VpcId == *filter.Values[0] {
|
||||||
|
match = true
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if strings.HasPrefix(*filter.Name, "tag:") {
|
if strings.HasPrefix(*filter.Name, "tag:") {
|
||||||
match = m.hasTag(ec2.ResourceTypeSubnet, *subnet.main.SubnetId, filter)
|
match = m.hasTag(ec2.ResourceTypeSubnet, *subnet.main.SubnetId, filter)
|
||||||
|
|
|
@ -26,6 +26,9 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/kops/cmd/kops/util"
|
"k8s.io/kops/cmd/kops/util"
|
||||||
|
@ -33,6 +36,7 @@ import (
|
||||||
"k8s.io/kops/pkg/diff"
|
"k8s.io/kops/pkg/diff"
|
||||||
"k8s.io/kops/pkg/kopscodecs"
|
"k8s.io/kops/pkg/kopscodecs"
|
||||||
"k8s.io/kops/pkg/testutils"
|
"k8s.io/kops/pkg/testutils"
|
||||||
|
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MagicTimestamp = metav1.Time{Time: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)}
|
var MagicTimestamp = metav1.Time{Time: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)}
|
||||||
|
@ -84,6 +88,24 @@ func TestCreateClusterWithNGWSpecified(t *testing.T) {
|
||||||
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/ngwspecified", "v1alpha2")
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/ngwspecified", "v1alpha2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestCreateClusterSharedVPC runs kops create cluster vpc.example.com --zones us-test-1a --master-zones us-test-1a --vpc vpc-12345678
|
||||||
|
func TestCreateClusterSharedVPC(t *testing.T) {
|
||||||
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/shared_vpc", "v1alpha1")
|
||||||
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/shared_vpc", "v1alpha2")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCreateClusterSharedSubnets runs kops create cluster subnet.example.com --zones us-test-1a --master-zones us-test-1a --vpc vpc-12345678 --subnets subnet-1
|
||||||
|
func TestCreateClusterSharedSubnets(t *testing.T) {
|
||||||
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/shared_subnets", "v1alpha1")
|
||||||
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/shared_subnets", "v1alpha2")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCreateClusterPrivateSharedSubnets runs kops create cluster private-subnet.example.com --zones us-test-1a --master-zones us-test-1a --vpc vpc-12345678 --subnets subnet-1 --utility-subnets subnet-2
|
||||||
|
func TestCreateClusterPrivateSharedSubnets(t *testing.T) {
|
||||||
|
// Cannot be expressed in v1alpha1 API: runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/private_shared_subnets", "v1alpha1")
|
||||||
|
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/private_shared_subnets", "v1alpha2")
|
||||||
|
}
|
||||||
|
|
||||||
func runCreateClusterIntegrationTest(t *testing.T, srcDir string, version string) {
|
func runCreateClusterIntegrationTest(t *testing.T, srcDir string, version string) {
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
|
|
||||||
|
@ -99,6 +121,24 @@ func runCreateClusterIntegrationTest(t *testing.T, srcDir string, version string
|
||||||
h.SetupMockAWS()
|
h.SetupMockAWS()
|
||||||
h.SetupMockGCE()
|
h.SetupMockGCE()
|
||||||
|
|
||||||
|
cloudTags := map[string]string{}
|
||||||
|
awsCloud, _ := awsup.NewAWSCloud("us-test-1", cloudTags)
|
||||||
|
awsCloud.EC2().CreateVpc(&ec2.CreateVpcInput{
|
||||||
|
CidrBlock: aws.String("10.0.0.0/12"),
|
||||||
|
})
|
||||||
|
|
||||||
|
awsCloud.EC2().CreateSubnet(&ec2.CreateSubnetInput{
|
||||||
|
AvailabilityZone: aws.String("us-test-1a"),
|
||||||
|
VpcId: aws.String("vpc-12345678"),
|
||||||
|
CidrBlock: aws.String("10.10.0.0/24"),
|
||||||
|
})
|
||||||
|
|
||||||
|
awsCloud.EC2().CreateSubnet(&ec2.CreateSubnetInput{
|
||||||
|
AvailabilityZone: aws.String("us-test-1a"),
|
||||||
|
VpcId: aws.String("vpc-12345678"),
|
||||||
|
CidrBlock: aws.String("10.11.0.0/24"),
|
||||||
|
})
|
||||||
|
|
||||||
publicKeyPath := path.Join(h.TempDir, "id_rsa.pub")
|
publicKeyPath := path.Join(h.TempDir, "id_rsa.pub")
|
||||||
privateKeyPath := path.Join(h.TempDir, "id_rsa")
|
privateKeyPath := path.Join(h.TempDir, "id_rsa")
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
name: private-subnets.example.com
|
||||||
|
spec:
|
||||||
|
api:
|
||||||
|
loadBalancer:
|
||||||
|
type: Public
|
||||||
|
authorization:
|
||||||
|
alwaysAllow: {}
|
||||||
|
channel: stable
|
||||||
|
cloudProvider: aws
|
||||||
|
configBase: memfs://tests/private-subnets.example.com
|
||||||
|
etcdClusters:
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: main
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: events
|
||||||
|
iam:
|
||||||
|
allowContainerRegistry: true
|
||||||
|
legacy: false
|
||||||
|
kubernetesApiAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
kubernetesVersion: v1.4.8
|
||||||
|
masterPublicName: api.private-subnets.example.com
|
||||||
|
networkCIDR: 10.0.0.0/12
|
||||||
|
networkID: vpc-12345678
|
||||||
|
networking:
|
||||||
|
kopeio: {}
|
||||||
|
nonMasqueradeCIDR: 100.64.0.0/10
|
||||||
|
sshAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
subnets:
|
||||||
|
- cidr: 10.10.0.0/24
|
||||||
|
id: subnet-1
|
||||||
|
name: us-test-1a
|
||||||
|
type: Private
|
||||||
|
zone: us-test-1a
|
||||||
|
- cidr: 10.11.0.0/24
|
||||||
|
id: subnet-2
|
||||||
|
name: utility-us-test-1a
|
||||||
|
type: Utility
|
||||||
|
zone: us-test-1a
|
||||||
|
topology:
|
||||||
|
dns:
|
||||||
|
type: Public
|
||||||
|
masters: private
|
||||||
|
nodes: private
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: private-subnets.example.com
|
||||||
|
name: master-us-test-1a
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: m3.medium
|
||||||
|
maxSize: 1
|
||||||
|
minSize: 1
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: master-us-test-1a
|
||||||
|
role: Master
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: private-subnets.example.com
|
||||||
|
name: nodes
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: t2.medium
|
||||||
|
maxSize: 2
|
||||||
|
minSize: 2
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: nodes
|
||||||
|
role: Node
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
|
@ -0,0 +1,12 @@
|
||||||
|
ClusterName: private-subnets.example.com
|
||||||
|
Zones:
|
||||||
|
- us-test-1a
|
||||||
|
Cloud: aws
|
||||||
|
Topology: private
|
||||||
|
Networking: kopeio-vxlan
|
||||||
|
VPCID: vpc-12345678
|
||||||
|
SubnetIDs:
|
||||||
|
- subnet-1
|
||||||
|
UtilitySubnetIDs:
|
||||||
|
- subnet-2
|
||||||
|
KubernetesVersion: v1.4.8
|
|
@ -0,0 +1,83 @@
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
name: subnet.example.com
|
||||||
|
spec:
|
||||||
|
adminAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
api:
|
||||||
|
dns: {}
|
||||||
|
authorization:
|
||||||
|
alwaysAllow: {}
|
||||||
|
channel: stable
|
||||||
|
cloudProvider: aws
|
||||||
|
configBase: memfs://tests/subnet.example.com
|
||||||
|
etcdClusters:
|
||||||
|
- etcdMembers:
|
||||||
|
- name: a
|
||||||
|
zone: us-test-1a
|
||||||
|
name: main
|
||||||
|
- etcdMembers:
|
||||||
|
- name: a
|
||||||
|
zone: us-test-1a
|
||||||
|
name: events
|
||||||
|
iam:
|
||||||
|
allowContainerRegistry: true
|
||||||
|
legacy: false
|
||||||
|
kubernetesVersion: v1.4.8
|
||||||
|
masterPublicName: api.subnet.example.com
|
||||||
|
networkCIDR: 10.0.0.0/12
|
||||||
|
networkID: vpc-12345678
|
||||||
|
networking:
|
||||||
|
kubenet: {}
|
||||||
|
nonMasqueradeCIDR: 100.64.0.0/10
|
||||||
|
topology:
|
||||||
|
dns:
|
||||||
|
type: Public
|
||||||
|
masters: public
|
||||||
|
nodes: public
|
||||||
|
zones:
|
||||||
|
- cidr: 10.10.0.0/24
|
||||||
|
id: subnet-1
|
||||||
|
name: us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: subnet.example.com
|
||||||
|
name: master-us-test-1a
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: m3.medium
|
||||||
|
maxSize: 1
|
||||||
|
minSize: 1
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: master-us-test-1a
|
||||||
|
role: Master
|
||||||
|
zones:
|
||||||
|
- us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: subnet.example.com
|
||||||
|
name: nodes
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: t2.medium
|
||||||
|
maxSize: 2
|
||||||
|
minSize: 2
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: nodes
|
||||||
|
role: Node
|
||||||
|
zones:
|
||||||
|
- us-test-1a
|
|
@ -0,0 +1,87 @@
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
name: subnet.example.com
|
||||||
|
spec:
|
||||||
|
api:
|
||||||
|
dns: {}
|
||||||
|
authorization:
|
||||||
|
alwaysAllow: {}
|
||||||
|
channel: stable
|
||||||
|
cloudProvider: aws
|
||||||
|
configBase: memfs://tests/subnet.example.com
|
||||||
|
etcdClusters:
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: main
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: events
|
||||||
|
iam:
|
||||||
|
allowContainerRegistry: true
|
||||||
|
legacy: false
|
||||||
|
kubernetesApiAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
kubernetesVersion: v1.4.8
|
||||||
|
masterPublicName: api.subnet.example.com
|
||||||
|
networkCIDR: 10.0.0.0/12
|
||||||
|
networkID: vpc-12345678
|
||||||
|
networking:
|
||||||
|
kubenet: {}
|
||||||
|
nonMasqueradeCIDR: 100.64.0.0/10
|
||||||
|
sshAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
subnets:
|
||||||
|
- cidr: 10.10.0.0/24
|
||||||
|
id: subnet-1
|
||||||
|
name: us-test-1a
|
||||||
|
type: Public
|
||||||
|
zone: us-test-1a
|
||||||
|
topology:
|
||||||
|
dns:
|
||||||
|
type: Public
|
||||||
|
masters: public
|
||||||
|
nodes: public
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: subnet.example.com
|
||||||
|
name: master-us-test-1a
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: m3.medium
|
||||||
|
maxSize: 1
|
||||||
|
minSize: 1
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: master-us-test-1a
|
||||||
|
role: Master
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: subnet.example.com
|
||||||
|
name: nodes
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: t2.medium
|
||||||
|
maxSize: 2
|
||||||
|
minSize: 2
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: nodes
|
||||||
|
role: Node
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
|
@ -0,0 +1,8 @@
|
||||||
|
ClusterName: subnet.example.com
|
||||||
|
Zones:
|
||||||
|
- us-test-1a
|
||||||
|
Cloud: aws
|
||||||
|
VPCID: vpc-12345678
|
||||||
|
SubnetIDs:
|
||||||
|
- subnet-1
|
||||||
|
KubernetesVersion: v1.4.8
|
|
@ -0,0 +1,82 @@
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
name: vpc.example.com
|
||||||
|
spec:
|
||||||
|
adminAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
api:
|
||||||
|
dns: {}
|
||||||
|
authorization:
|
||||||
|
alwaysAllow: {}
|
||||||
|
channel: stable
|
||||||
|
cloudProvider: aws
|
||||||
|
configBase: memfs://tests/vpc.example.com
|
||||||
|
etcdClusters:
|
||||||
|
- etcdMembers:
|
||||||
|
- name: a
|
||||||
|
zone: us-test-1a
|
||||||
|
name: main
|
||||||
|
- etcdMembers:
|
||||||
|
- name: a
|
||||||
|
zone: us-test-1a
|
||||||
|
name: events
|
||||||
|
iam:
|
||||||
|
allowContainerRegistry: true
|
||||||
|
legacy: false
|
||||||
|
kubernetesVersion: v1.4.8
|
||||||
|
masterPublicName: api.vpc.example.com
|
||||||
|
networkCIDR: 10.0.0.0/12
|
||||||
|
networkID: vpc-12345678
|
||||||
|
networking:
|
||||||
|
kubenet: {}
|
||||||
|
nonMasqueradeCIDR: 100.64.0.0/10
|
||||||
|
topology:
|
||||||
|
dns:
|
||||||
|
type: Public
|
||||||
|
masters: public
|
||||||
|
nodes: public
|
||||||
|
zones:
|
||||||
|
- cidr: 10.2.0.0/15
|
||||||
|
name: us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: vpc.example.com
|
||||||
|
name: master-us-test-1a
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: m3.medium
|
||||||
|
maxSize: 1
|
||||||
|
minSize: 1
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: master-us-test-1a
|
||||||
|
role: Master
|
||||||
|
zones:
|
||||||
|
- us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha1
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: vpc.example.com
|
||||||
|
name: nodes
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: t2.medium
|
||||||
|
maxSize: 2
|
||||||
|
minSize: 2
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: nodes
|
||||||
|
role: Node
|
||||||
|
zones:
|
||||||
|
- us-test-1a
|
|
@ -0,0 +1,86 @@
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
name: vpc.example.com
|
||||||
|
spec:
|
||||||
|
api:
|
||||||
|
dns: {}
|
||||||
|
authorization:
|
||||||
|
alwaysAllow: {}
|
||||||
|
channel: stable
|
||||||
|
cloudProvider: aws
|
||||||
|
configBase: memfs://tests/vpc.example.com
|
||||||
|
etcdClusters:
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: main
|
||||||
|
- etcdMembers:
|
||||||
|
- instanceGroup: master-us-test-1a
|
||||||
|
name: a
|
||||||
|
name: events
|
||||||
|
iam:
|
||||||
|
allowContainerRegistry: true
|
||||||
|
legacy: false
|
||||||
|
kubernetesApiAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
kubernetesVersion: v1.4.8
|
||||||
|
masterPublicName: api.vpc.example.com
|
||||||
|
networkCIDR: 10.0.0.0/12
|
||||||
|
networkID: vpc-12345678
|
||||||
|
networking:
|
||||||
|
kubenet: {}
|
||||||
|
nonMasqueradeCIDR: 100.64.0.0/10
|
||||||
|
sshAccess:
|
||||||
|
- 0.0.0.0/0
|
||||||
|
subnets:
|
||||||
|
- cidr: 10.2.0.0/15
|
||||||
|
name: us-test-1a
|
||||||
|
type: Public
|
||||||
|
zone: us-test-1a
|
||||||
|
topology:
|
||||||
|
dns:
|
||||||
|
type: Public
|
||||||
|
masters: public
|
||||||
|
nodes: public
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: vpc.example.com
|
||||||
|
name: master-us-test-1a
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: m3.medium
|
||||||
|
maxSize: 1
|
||||||
|
minSize: 1
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: master-us-test-1a
|
||||||
|
role: Master
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: kops/v1alpha2
|
||||||
|
kind: InstanceGroup
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: 2017-01-01T00:00:00Z
|
||||||
|
labels:
|
||||||
|
kops.k8s.io/cluster: vpc.example.com
|
||||||
|
name: nodes
|
||||||
|
spec:
|
||||||
|
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
|
||||||
|
machineType: t2.medium
|
||||||
|
maxSize: 2
|
||||||
|
minSize: 2
|
||||||
|
nodeLabels:
|
||||||
|
kops.k8s.io/instancegroup: nodes
|
||||||
|
role: Node
|
||||||
|
subnets:
|
||||||
|
- us-test-1a
|
|
@ -0,0 +1,6 @@
|
||||||
|
ClusterName: vpc.example.com
|
||||||
|
Zones:
|
||||||
|
- us-test-1a
|
||||||
|
Cloud: aws
|
||||||
|
VPCID: vpc-12345678
|
||||||
|
KubernetesVersion: v1.4.8
|
|
@ -872,6 +872,10 @@ func (c *awsCloudImplementation) DescribeInstance(instanceID string) (*ec2.Insta
|
||||||
|
|
||||||
// DescribeVPC is a helper that queries for the specified vpc by id
|
// DescribeVPC is a helper that queries for the specified vpc by id
|
||||||
func (c *awsCloudImplementation) DescribeVPC(vpcID string) (*ec2.Vpc, error) {
|
func (c *awsCloudImplementation) DescribeVPC(vpcID string) (*ec2.Vpc, error) {
|
||||||
|
return describeVPC(c, vpcID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func describeVPC(c AWSCloud, vpcID string) (*ec2.Vpc, error) {
|
||||||
glog.V(2).Infof("Calling DescribeVPC for VPC %q", vpcID)
|
glog.V(2).Infof("Calling DescribeVPC for VPC %q", vpcID)
|
||||||
request := &ec2.DescribeVpcsInput{
|
request := &ec2.DescribeVpcsInput{
|
||||||
VpcIds: []*string{&vpcID},
|
VpcIds: []*string{&vpcID},
|
||||||
|
@ -1034,6 +1038,10 @@ func (c *awsCloudImplementation) Route53() route53iface.Route53API {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *awsCloudImplementation) FindVPCInfo(vpcID string) (*fi.VPCInfo, error) {
|
func (c *awsCloudImplementation) FindVPCInfo(vpcID string) (*fi.VPCInfo, error) {
|
||||||
|
return findVPCInfo(c, vpcID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func findVPCInfo(c AWSCloud, vpcID string) (*fi.VPCInfo, error) {
|
||||||
vpc, err := c.DescribeVPC(vpcID)
|
vpc, err := c.DescribeVPC(vpcID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1053,7 +1061,7 @@ func (c *awsCloudImplementation) FindVPCInfo(vpcID string) (*fi.VPCInfo, error)
|
||||||
Filters: []*ec2.Filter{NewEC2Filter("vpc-id", vpcID)},
|
Filters: []*ec2.Filter{NewEC2Filter("vpc-id", vpcID)},
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := c.ec2.DescribeSubnets(request)
|
response, err := c.EC2().DescribeSubnets(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error listing subnets in VPC %q: %v", vpcID, err)
|
return nil, fmt.Errorf("error listing subnets in VPC %q: %v", vpcID, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2.Instance, error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockAWSCloud) DescribeVPC(vpcID string) (*ec2.Vpc, error) {
|
func (c *MockAWSCloud) DescribeVPC(vpcID string) (*ec2.Vpc, error) {
|
||||||
return nil, fmt.Errorf("MockAWSCloud DescribeVPC not implemented")
|
return describeVPC(c, vpcID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockAWSCloud) ResolveImage(name string) (*ec2.Image, error) {
|
func (c *MockAWSCloud) ResolveImage(name string) (*ec2.Image, error) {
|
||||||
|
@ -214,7 +214,7 @@ func (c *MockAWSCloud) Route53() route53iface.Route53API {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockAWSCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
|
func (c *MockAWSCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
|
||||||
return nil, fmt.Errorf("MockAWSCloud FindVPCInfo not implemented")
|
return findVPCInfo(c, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultInstanceType determines an instance type for the specified cluster & instance group
|
// DefaultInstanceType determines an instance type for the specified cluster & instance group
|
||||||
|
|
Loading…
Reference in New Issue