From 9631131dafece0e94eb3450ad1b42d6086b8eb85 Mon Sep 17 00:00:00 2001 From: Robert Ross Date: Thu, 1 Feb 2018 15:48:50 -0500 Subject: [PATCH] Define load balancers on the group yaml level --- cmd/k8s-pipeliner/main.go | 2 +- pipeline/builder/builder.go | 9 +-------- pipeline/builder/kubernetes.go | 5 ----- pipeline/config/config.go | 13 +++++++------ test-pipeline.yml | 2 ++ 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/cmd/k8s-pipeliner/main.go b/cmd/k8s-pipeliner/main.go index 87bc556..d80b61f 100644 --- a/cmd/k8s-pipeliner/main.go +++ b/cmd/k8s-pipeliner/main.go @@ -14,7 +14,7 @@ import ( const ( // Version defines the current version of k8s-pipeliner - Version = "0.0.5" + Version = "0.0.6" ) func main() { diff --git a/pipeline/builder/builder.go b/pipeline/builder/builder.go index 3262d93..8f527e6 100644 --- a/pipeline/builder/builder.go +++ b/pipeline/builder/builder.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "strings" "github.com/namely/k8s-pipeliner/pipeline/builder/types" "github.com/namely/k8s-pipeliner/pipeline/config" @@ -157,17 +156,11 @@ func (b *Builder) buildDeployStage(index int, s config.Stage) (*types.DeployStag } } - // grab the load balancers for the deployment - var lbs []string - if l, ok := mg.Annotations[SpinnakerLoadBalancersAnnotations]; ok { - lbs = strings.Split(l, ",") - } - cluster := types.Cluster{ Account: s.Account, Application: b.pipeline.Application, Containers: mg.Containers, - LoadBalancers: lbs, + LoadBalancers: group.LoadBalancers, Region: mg.Namespace, Namespace: mg.Namespace, MaxRemainingAsgs: group.MaxRemainingASGS, diff --git a/pipeline/builder/kubernetes.go b/pipeline/builder/kubernetes.go index 911ca42..39fb417 100644 --- a/pipeline/builder/kubernetes.go +++ b/pipeline/builder/kubernetes.go @@ -45,11 +45,6 @@ const ( // SpinnakerImageDescriptionOrganizationAnnotation is the registry org that owns the image. // Example: "namely" (where registry.namely.land/namely <- is the org) SpinnakerImageDescriptionOrganizationAnnotation = "namely.com/spinnaker-image-description-organization" - - // SpinnakerLoadBalancersAnnotations is a comma separated list of load balancers - // defined in Spinnaker that should be attached to a cluster - // Example: "catalog,catalog-public" - SpinnakerLoadBalancersAnnotations = "namely.com/spinnaker-load-balancers" ) // ManifestGroup keeps a collection of containers from a deployment diff --git a/pipeline/config/config.go b/pipeline/config/config.go index 82e7c05..865136d 100644 --- a/pipeline/config/config.go +++ b/pipeline/config/config.go @@ -91,12 +91,13 @@ type DeployStage struct { // of a group is filled out by the defined manifest file. This means things like commands, env vars, // etc, are all pulled into the group spec for you. type Group struct { - ManifestFile string `yaml:"manifestFile"` - MaxRemainingASGS int `yaml:"maxRemainingASGS"` - ScaleDown bool `yaml:"scaleDown"` - Stack string `yaml:"stack"` - Strategy string `yaml:"strategy"` - TargetSize int `yaml:"targetSize"` + ManifestFile string `yaml:"manifestFile"` + MaxRemainingASGS int `yaml:"maxRemainingASGS"` + ScaleDown bool `yaml:"scaleDown"` + Stack string `yaml:"stack"` + Strategy string `yaml:"strategy"` + TargetSize int `yaml:"targetSize"` + LoadBalancers []string `yaml:"loadBalancers"` // If overrides are provided, the group will run a check to make sure // the given manifest only defines one container. If it does, the given diff --git a/test-pipeline.yml b/test-pipeline.yml index dcf3c7f..0fbc0b9 100644 --- a/test-pipeline.yml +++ b/test-pipeline.yml @@ -42,6 +42,8 @@ stages: strategy: redblack targetSize: 2 # this is the total amount of replicas for the deployment containerOverrides: {} + loadBalancers: + - "test" - account: int-k8s name: "Proceed to Staging?" refId: "3"