From b4b1ebaa2ee9f48cf8c12805cfbdef1af5cebe01 Mon Sep 17 00:00:00 2001 From: Pieter Lange Date: Thu, 24 Nov 2016 13:10:26 +0100 Subject: [PATCH] Option to automatically assign externally managed ELBs to the worker autoscaling group --- config/config.go | 44 +++++++++++++++++----------- config/templates/cluster.yaml | 4 +++ config/templates/stack-template.json | 19 ++++++++++-- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/config/config.go b/config/config.go index d2fcaa770..bfc46ddf4 100644 --- a/config/config.go +++ b/config/config.go @@ -31,12 +31,6 @@ const ( func newDefaultCluster() *Cluster { experimental := Experimental{ - NodeDrainer{ - Enabled: false, - }, - NodeLabel{ - Enabled: false, - }, AwsEnvironment{ Enabled: false, }, @@ -45,6 +39,15 @@ func newDefaultCluster() *Cluster { Disk: "xvdb", Filesystem: "xfs", }, + LoadBalancer{ + Enabled: false, + }, + NodeDrainer{ + Enabled: false, + }, + NodeLabel{ + Enabled: false, + }, WaitSignal{ Enabled: false, MaxBatchSize: 1, @@ -208,13 +211,25 @@ type Subnet struct { } type Experimental struct { - NodeDrainer NodeDrainer `yaml:"nodeDrainer"` - NodeLabel NodeLabel `yaml:"nodeLabel"` AwsEnvironment AwsEnvironment `yaml:"awsEnvironment"` EphemeralImageStorage EphemeralImageStorage `yaml:"ephemeralImageStorage"` + LoadBalancer LoadBalancer `yaml:"loadBalancer"` + NodeDrainer NodeDrainer `yaml:"nodeDrainer"` + NodeLabel NodeLabel `yaml:"nodeLabel"` WaitSignal WaitSignal `yaml:"waitSignal"` } +type AwsEnvironment struct { + Enabled bool `yaml:"enabled"` + Environment map[string]string `yaml:"environment"` +} + +type EphemeralImageStorage struct { + Enabled bool `yaml:"enabled"` + Disk string `yaml:"disk"` + Filesystem string `yaml:"filesystem"` +} + type NodeDrainer struct { Enabled bool `yaml:"enabled"` } @@ -223,9 +238,10 @@ type NodeLabel struct { Enabled bool `yaml:"enabled"` } -type AwsEnvironment struct { - Enabled bool `yaml:"enabled"` - Environment map[string]string `yaml:"environment"` +type LoadBalancer struct { + Enabled bool `yaml:"enabled"` + Names []string `yaml:"names"` + SecurityGroupIds []string `yaml:"securityGroupIds"` } type WaitSignal struct { @@ -233,12 +249,6 @@ type WaitSignal struct { MaxBatchSize int `yaml:"maxBatchSize"` } -type EphemeralImageStorage struct { - Enabled bool `yaml:"enabled"` - Disk string `yaml:"disk"` - Filesystem string `yaml:"filesystem"` -} - const ( vpcLogicalName = "VPC" ) diff --git a/config/templates/cluster.yaml b/config/templates/cluster.yaml index e908fa187..69af6f8c4 100644 --- a/config/templates/cluster.yaml +++ b/config/templates/cluster.yaml @@ -192,6 +192,10 @@ kmsKeyArn: "{{.KMSKeyARN}}" # # This option has not yet been tested with rkt as container runtime # ephemeralImageStorage: # enabled: true +# loadBalancer: +# enabled: true +# names: [ "manuallymanagedelb" ] +# securityGroupIds: [ "sg-87654321" ] # AWS Tags for cloudformation stack resources #stackTags: diff --git a/config/templates/stack-template.json b/config/templates/stack-template.json index f055eeb55..28a9b74ca 100644 --- a/config/templates/stack-template.json +++ b/config/templates/stack-template.json @@ -37,6 +37,14 @@ "Value": "{{.ClusterName}}-kube-aws-worker" } ], + {{if .Experimental.LoadBalancer.Enabled}} + "LoadBalancerNames" : [ + {{range $index, $elb := .Experimental.LoadBalancer.Names}} + {{if $index}},{{end}} + "{{$elb}}" + {{end}} + ], + {{end}} "VPCZoneIdentifier": [ {{range $index, $subnet := .Subnets}} {{with $subnetLogicalName := printf "Subnet%d" $index}} @@ -116,9 +124,9 @@ {{end}} {{end}} ], - "LoadBalancerNames" : [ - { "Ref" : "ElbAPIServer" } - ] + "LoadBalancerNames" : [ + { "Ref" : "ElbAPIServer" } + ] }, {{if .Experimental.WaitSignal.Enabled}} "CreationPolicy" : { @@ -477,6 +485,11 @@ "InstanceType": "{{.WorkerInstanceType}}", "KeyName": "{{.KeyName}}", "SecurityGroups": [ + {{if .Experimental.LoadBalancer.Enabled}} + {{range $elbsg := .Experimental.LoadBalancer.SecurityGroupIds}} + "{{$elbsg}}", + {{end}} + {{end}} { "Ref": "SecurityGroupWorker" }