Skip to content

Commit

Permalink
Refactoring phases to work in sequence properly
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislovecnm committed Oct 26, 2017
1 parent ceafc68 commit dc338c4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 257 deletions.
11 changes: 6 additions & 5 deletions pkg/model/awsmodel/api_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const LoadBalancerDefaultIdleTimeout = 5 * time.Minute
// APILoadBalancerBuilder builds a LoadBalancer for accessing the API
type APILoadBalancerBuilder struct {
*AWSModelContext
Lifecycle *fi.Lifecycle
Lifecycle *fi.Lifecycle
SecurityLifecycle *fi.Lifecycle
}

var _ fi.ModelBuilder = &APILoadBalancerBuilder{}
Expand Down Expand Up @@ -144,7 +145,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroup{
Name: s(b.ELBSecurityGroupName("api")),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

VPC: b.LinkToVPC(),
Description: s("Security group for api ELB"),
Expand All @@ -157,7 +158,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("api-elb-egress"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToELBSecurityGroup("api"),
Egress: fi.Bool(true),
Expand All @@ -171,7 +172,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
for _, cidr := range b.Cluster.Spec.KubernetesAPIAccess {
t := &awstasks.SecurityGroupRule{
Name: s("https-api-elb-" + cidr),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToELBSecurityGroup("api"),
CIDR: s(cidr),
Expand All @@ -187,7 +188,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("https-elb-to-master"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleMaster),
SourceGroup: b.LinkToELBSecurityGroup("api"),
Expand Down
19 changes: 10 additions & 9 deletions pkg/model/bastion.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const BastionELBDefaultIdleTimeout = 5 * time.Minute

type BastionModelBuilder struct {
*KopsModelContext
Lifecycle *fi.Lifecycle
Lifecycle *fi.Lifecycle
SecurityLifecycle *fi.Lifecycle
}

var _ fi.ModelBuilder = &BastionModelBuilder{}
Expand All @@ -56,7 +57,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroup{
Name: s(b.SecurityGroupName(kops.InstanceGroupRoleBastion)),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

VPC: b.LinkToVPC(),
Description: s("Security group for bastion"),
Expand All @@ -69,7 +70,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("bastion-egress"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleBastion),
Egress: fi.Bool(true),
Expand All @@ -83,7 +84,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("ssh-elb-to-bastion"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleBastion),
SourceGroup: b.LinkToELBSecurityGroup(BastionELBSecurityGroupPrefix),
Expand All @@ -98,7 +99,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("bastion-to-master-ssh"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleMaster),
SourceGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleBastion),
Expand All @@ -113,7 +114,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("bastion-to-node-ssh"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleNode),
SourceGroup: b.LinkToSecurityGroup(kops.InstanceGroupRoleBastion),
Expand All @@ -128,7 +129,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroup{
Name: s(b.ELBSecurityGroupName(BastionELBSecurityGroupPrefix)),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

VPC: b.LinkToVPC(),
Description: s("Security group for bastion ELB"),
Expand All @@ -141,7 +142,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
{
t := &awstasks.SecurityGroupRule{
Name: s("bastion-elb-egress"),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToELBSecurityGroup(BastionELBSecurityGroupPrefix),
Egress: fi.Bool(true),
Expand All @@ -155,7 +156,7 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
for _, sshAccess := range b.Cluster.Spec.SSHAccess {
t := &awstasks.SecurityGroupRule{
Name: s("ssh-external-to-bastion-elb-" + sshAccess),
Lifecycle: b.Lifecycle,
Lifecycle: b.SecurityLifecycle,

SecurityGroup: b.LinkToELBSecurityGroup(BastionELBSecurityGroupPrefix),
Protocol: s("tcp"),
Expand Down

This file was deleted.

16 changes: 8 additions & 8 deletions upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,11 @@ func (c *ApplyClusterCmd) Run() error {

l.Builders = append(l.Builders,
&model.MasterVolumeBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle},
&awsmodel.APILoadBalancerBuilder{AWSModelContext: awsModelContext, Lifecycle: networkLifecycle},
&model.BastionModelBuilder{KopsModelContext: modelContext, Lifecycle: networkLifecycle},
&model.DNSModelBuilder{KopsModelContext: modelContext, Lifecycle: networkLifecycle},
&model.ExternalAccessModelBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle},
&model.FirewallModelBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle},
&awsmodel.APILoadBalancerBuilder{AWSModelContext: awsModelContext, Lifecycle: clusterLifecycle, SecurityLifecycle: securityLifecycle},
&model.BastionModelBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle, SecurityLifecycle: securityLifecycle},
&model.DNSModelBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle},
&model.ExternalAccessModelBuilder{KopsModelContext: modelContext, Lifecycle: securityLifecycle},
&model.FirewallModelBuilder{KopsModelContext: modelContext, Lifecycle: securityLifecycle},
&model.SSHKeyModelBuilder{KopsModelContext: modelContext, Lifecycle: securityLifecycle},
)

Expand All @@ -563,9 +563,9 @@ func (c *ApplyClusterCmd) Run() error {
l.Builders = append(l.Builders,
&model.MasterVolumeBuilder{KopsModelContext: modelContext, Lifecycle: clusterLifecycle},

&gcemodel.APILoadBalancerBuilder{GCEModelContext: gceModelContext, Lifecycle: networkLifecycle},
&gcemodel.ExternalAccessModelBuilder{GCEModelContext: gceModelContext, Lifecycle: networkLifecycle},
&gcemodel.FirewallModelBuilder{GCEModelContext: gceModelContext, Lifecycle: networkLifecycle},
&gcemodel.APILoadBalancerBuilder{GCEModelContext: gceModelContext, Lifecycle: securityLifecycle},
&gcemodel.ExternalAccessModelBuilder{GCEModelContext: gceModelContext, Lifecycle: securityLifecycle},
&gcemodel.FirewallModelBuilder{GCEModelContext: gceModelContext, Lifecycle: securityLifecycle},
&gcemodel.NetworkModelBuilder{GCEModelContext: gceModelContext, Lifecycle: networkLifecycle},
)

Expand Down

0 comments on commit dc338c4

Please sign in to comment.