deployer

package
v0.0.0-...-3f1c2bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCanaryVersion

func CheckCanaryVersion(tgs []*string, region string) int

CheckCanaryVersion checks latest version of canary target group

func CheckRegionExist

func CheckRegionExist(target string, regions []schemas.RegionConfig) bool

CheckRegionExist checks if target region is really in regions described in manifest file

func IfEmptyAutoscalingGroup

func IfEmptyAutoscalingGroup(desired int64, instances []*autoscaling.Instance) bool

IfEmptyAutoscalingGroup

func IsFinishedRollingUpdate

func IsFinishedRollingUpdate(current schemas.Capacity, target schemas.Capacity) bool

IsFinishedRollingUpdate checks if rolling update is done or not

func MakeCapacity

func MakeCapacity(min, max, desired int64) (*schemas.Capacity, error)

MakeCapacity makes capacity object with min,max,desired

func NeedToInitializeCapacity

func NeedToInitializeCapacity(mode string, completeCanary bool) bool

NeedToInitializeCapacity checks if deployment process needs initialized capacity If this value is true, then capacity will be adjusted to min: 1,desired: 1,max: 1

func RetrieveNextCapacity

func RetrieveNextCapacity(capacity *schemas.Capacity, targetCapacity schemas.Capacity, increaseInstanceCount int64) error

RetrieveNextCapacity add one capacity at a time

Types

type APIAttacker

type APIAttacker struct {
	Name     string
	Attacker *vegeta.Attacker
	Rate     vegeta.Rate
	Duration time.Duration
	Targets  []vegeta.Target
}

func (APIAttacker) Print

func (a APIAttacker) Print(metrics []schemas.MetricResult) (string, error)

Print shows results

func (APIAttacker) Run

func (a APIAttacker) Run() ([]schemas.MetricResult, error)

Run calls apis to check

type BlueGreen

type BlueGreen struct {
	*Deployer
}

func NewBlueGreen

func NewBlueGreen(h *helper.DeployerHelper) *BlueGreen

NewBlueGreen creates new BlueGreen deployment deployer

func (*BlueGreen) CheckPreviousResources

func (b *BlueGreen) CheckPreviousResources(config schemas.Config) error

CheckPreviousResources checks if there is any previous version of autoscaling group

func (*BlueGreen) CleanChecking

func (b *BlueGreen) CleanChecking(config schemas.Config) error

CleanChecking checks Termination status

func (*BlueGreen) CleanPreviousVersion

func (b *BlueGreen) CleanPreviousVersion(config schemas.Config) error

CleanPreviousVersion cleans previous version of autoscaling group

func (*BlueGreen) Deploy

func (b *BlueGreen) Deploy(config schemas.Config) error

Deploy function

func (*BlueGreen) FinishAdditionalWork

func (b *BlueGreen) FinishAdditionalWork(config schemas.Config) error

FinishAdditionalWork processes additional work for the new deployment

func (*BlueGreen) GatherMetrics

func (b *BlueGreen) GatherMetrics(config schemas.Config) error

GatherMetrics gathers the whole metrics from deployer

func (*BlueGreen) GetDeployer

func (b *BlueGreen) GetDeployer() *Deployer

GetDeployer returns Deployer struct

func (*BlueGreen) HealthChecking

func (b *BlueGreen) HealthChecking(config schemas.Config) error

HealthChecking does health checking for blue-green deployment

func (*BlueGreen) RunAPITest

func (b *BlueGreen) RunAPITest(config schemas.Config) error

RunAPITest tries to run API Test

func (*BlueGreen) TriggerLifecycleCallbacks

func (b *BlueGreen) TriggerLifecycleCallbacks(config schemas.Config) error

TriggerLifecycleCallbacks runs lifecycle callbacks before cleaning.

type Canary

type Canary struct {
	PrevTargetGroups            map[string][]string
	TargetGroups                map[string][]*string
	PrevHealthCheckTargetGroups map[string]string
	LoadBalancer                map[string]string
	LBSecurityGroup             map[string]*string
	*Deployer
}

func NewCanary

func NewCanary(h *helper.DeployerHelper) *Canary

NewCanary creates new canary deployment deployer

func (*Canary) AttachCanaryTargetGroup

func (c *Canary) AttachCanaryTargetGroup(lbArn, tgArn string, region schemas.RegionConfig) error

AttachCanaryTargetGroup attaches target group to load balancer

func (*Canary) AttachToOriginalTargetGroups

func (c *Canary) AttachToOriginalTargetGroups(config schemas.Config) error

AttachToOriginalTargetGroups attaches the new autoscaling group to original target groups

func (*Canary) ChangeLaunchTemplateVersion

func (c *Canary) ChangeLaunchTemplateVersion(asg string, lt *autoscaling.LaunchTemplateSpecification, region schemas.RegionConfig, excludeSg string) error

ChangeLaunchTemplateVersion changes launch template to the new version

func (*Canary) ChangeTargetGroupInfo

func (c *Canary) ChangeTargetGroupInfo(newTgName string, region schemas.RegionConfig) schemas.RegionConfig

ChangeTargetGroupInfo changes existing target group to the new one for canary deployment

func (*Canary) CheckPreviousResources

func (c *Canary) CheckPreviousResources(config schemas.Config) error

CheckPreviousResources checks if there is any previous version of autoscaling group

func (*Canary) CheckValidCanaryLB

func (c *Canary) CheckValidCanaryLB(app, lb string) bool

CheckValidCanaryLB checks if load balancer is canary-related or not

func (*Canary) CleanChecking

func (c *Canary) CleanChecking(config schemas.Config) error

CleanChecking checks Termination status

func (*Canary) CleanPreviousCanaryResources

func (c *Canary) CleanPreviousCanaryResources(region schemas.RegionConfig, completeCanary bool) error

CleanPreviousCanaryResources cleans previous canary resources

func (*Canary) CleanPreviousVersion

func (c *Canary) CleanPreviousVersion(config schemas.Config) error

CleanPreviousVersion cleans previous version of autoscaling group or canary target group

func (*Canary) CompleteCanaryDeployment

func (c *Canary) CompleteCanaryDeployment(config schemas.Config, region schemas.RegionConfig, latestASG string) error

CompleteCanaryDeployment completes canary deployment

func (*Canary) CopyTargetGroups

func (c *Canary) CopyTargetGroups(tg *elbv2.TargetGroup, canaryTgName, region string) (*elbv2.TargetGroup, error)

CopyTargetGroups creates copy existing target group for canary

func (*Canary) CreateCanaryLBSecurityGroup

func (c *Canary) CreateCanaryLBSecurityGroup(tg *elbv2.TargetGroup, region schemas.RegionConfig) (*string, error)

CreateCanaryLBSecurityGroup creates a new security group for canary

func (*Canary) CreateCanaryLoadBalancer

func (c *Canary) CreateCanaryLoadBalancer(region schemas.RegionConfig, groupID *string) (*elbv2.LoadBalancer, error)

CreateCanaryLoadBalancer creates a new load balancer for canary

func (*Canary) DeleteEC2IngressRules

func (c *Canary) DeleteEC2IngressRules(region schemas.RegionConfig) error

DeleteEC2IngressRules deletes ingress rules for EC2

func (*Canary) DeleteEC2SecurityGroup

func (c *Canary) DeleteEC2SecurityGroup(region schemas.RegionConfig) error

DeleteEC2SecurityGroup deletes EC2 security group for canary

func (*Canary) DeleteLBSecurityGroup

func (c *Canary) DeleteLBSecurityGroup(region schemas.RegionConfig) error

DeleteLBSecurityGroup deletes load balancer security group

func (*Canary) DeleteLoadBalancer

func (c *Canary) DeleteLoadBalancer(region schemas.RegionConfig) error

DeleteLoadBalancer deletes load balancer

func (*Canary) Deploy

func (c *Canary) Deploy(config schemas.Config) error

Deploy runs deployments with canary approach

func (*Canary) DetachCanaryTargetGroup

func (c *Canary) DetachCanaryTargetGroup(asg string, region schemas.RegionConfig, tgs []*string) error

DetachCanaryTargetGroup detaches canary target group from auto scaling group

func (*Canary) DetachSecurityGroup

func (c *Canary) DetachSecurityGroup(nis []*ec2.InstanceNetworkInterface, region schemas.RegionConfig, excludeSg string) error

DetachSecurityGroup deletes lb security groups from instances

func (*Canary) FindCanaryLoadBalancer

func (c *Canary) FindCanaryLoadBalancer(region schemas.RegionConfig) (*elbv2.LoadBalancer, error)

FindCanaryLoadBalancer finds if there is canary-related load balancer

func (*Canary) FinishAdditionalWork

func (c *Canary) FinishAdditionalWork(config schemas.Config) error

FinishAdditionalWork processes additional work for the new deployment

func (*Canary) GatherMetrics

func (c *Canary) GatherMetrics(config schemas.Config) error

GatherMetrics gathers the whole metrics from deployer

func (*Canary) GenerateCanaryLBSecurityGroupName

func (c *Canary) GenerateCanaryLBSecurityGroupName(region string) string

GenerateCanaryLBSecurityGroupName generates name of canary load balancer for canary

func (*Canary) GenerateCanaryLoadBalancerName

func (c *Canary) GenerateCanaryLoadBalancerName(region string) string

GenerateCanaryLoadBalancerName generates name of canary load balancer for canary

func (*Canary) GenerateCanarySecurityGroupName

func (c *Canary) GenerateCanarySecurityGroupName(region string) string

GenerateCanarySecurityGroupName generates name of canary load balancer for canary

func (*Canary) GenerateCanaryTargetGroupName

func (c *Canary) GenerateCanaryTargetGroupName(canaryVersion int) string

GenerateCanaryTargetGroupName generates name of canary target group for canary

func (*Canary) GetAsgTargetGroups

func (c *Canary) GetAsgTargetGroups(asg, region string) ([]*string, error)

GetAsgTargetGroups retrieves target group list of autoscaling group

func (*Canary) GetCanaryLoadBalancerSecurityGroup

func (c *Canary) GetCanaryLoadBalancerSecurityGroup(region schemas.RegionConfig) (*string, error)

GetCanaryLoadBalancerSecurityGroup retrieves existing load balancer security group for canary

func (*Canary) GetDeployer

func (c *Canary) GetDeployer() *Deployer

GetDeployer returns canary deployer

func (*Canary) GetEC2CanarySecurityGroup

func (c *Canary) GetEC2CanarySecurityGroup(tg *elbv2.TargetGroup, region schemas.RegionConfig, lbSg *string, completeCanary bool) error

GetEC2CanarySecurityGroup creates a new security group for canary

func (*Canary) GetLoadBalancerAndSecurityGroupForCanary

func (c *Canary) GetLoadBalancerAndSecurityGroupForCanary(region schemas.RegionConfig, tgDetail *elbv2.TargetGroup, completeCanary bool) (*string, *elbv2.LoadBalancer, error)

GetLoadBalancerAndSecurityGroupForCanary gets load balancer and security group for canary deployment

func (*Canary) HealthChecking

func (c *Canary) HealthChecking(config schemas.Config) error

HealthChecking does health checking for canary deployment

func (*Canary) LoadBalancerDeletionChecking

func (c *Canary) LoadBalancerDeletionChecking(region schemas.RegionConfig) error

LoadBalancerDeletionChecking checks if load balancer is deleted well or not

func (*Canary) ReduceOriginalAutoscalingGroupCount

func (c *Canary) ReduceOriginalAutoscalingGroupCount(region schemas.RegionConfig) error

ReduceOriginalAutoscalingGroupCount set existing autoscaling group count to -1

func (*Canary) RemoveCanaryTag

func (c *Canary) RemoveCanaryTag(asg string, region schemas.RegionConfig) error

RemoveCanaryTag deletes Canary tag from auto scaling group

func (*Canary) RunAPITest

func (c *Canary) RunAPITest(config schemas.Config) error

RunAPITest tries to run API Test

func (*Canary) RunCanaryDeployment

func (c *Canary) RunCanaryDeployment(config schemas.Config, region schemas.RegionConfig, tgDetail *elbv2.TargetGroup, canaryLoadBalancer *elbv2.LoadBalancer, canaryVersion int) (schemas.RegionConfig, error)

RunCanaryDeployment runs canary deployment

func (*Canary) SelectTargetGroupForCopy

func (c *Canary) SelectTargetGroupForCopy(region schemas.RegionConfig, canaryVersion int) string

SelectTargetGroupForCopy select target group for copy

func (*Canary) TriggerLifecycleCallbacks

func (c *Canary) TriggerLifecycleCallbacks(config schemas.Config) error

TriggerLifecycleCallbacks runs lifecycle callbacks before cleaning.

func (*Canary) ValidateCanaryDeployment

func (c *Canary) ValidateCanaryDeployment(config schemas.Config, region string) error

ValidateCanaryDeployment validates if configuration is right for canary deployment

type DeployManager

type DeployManager interface {
	GetDeployer() *Deployer
	CheckPreviousResources(config schemas.Config) error
	Deploy(config schemas.Config) error
	HealthChecking(config schemas.Config) error
	FinishAdditionalWork(config schemas.Config) error
	CleanPreviousVersion(config schemas.Config) error
	TriggerLifecycleCallbacks(config schemas.Config) error
	CleanChecking(config schemas.Config) error
	GatherMetrics(config schemas.Config) error
	RunAPITest(config schemas.Config) error
}

type DeployOnly

type DeployOnly struct {
	*Deployer
}

func NewDeployOnly

func NewDeployOnly(h *helper.DeployerHelper) *DeployOnly

NewDeployOnly creates new DeployOnly deployment deployer

func (*DeployOnly) CheckPreviousResources

func (d *DeployOnly) CheckPreviousResources(config schemas.Config) error

CheckPreviousResources checks if there is any previous version of autoscaling group

func (*DeployOnly) CleanChecking

func (d *DeployOnly) CleanChecking(config schemas.Config) error

CleanChecking checks Termination status

func (*DeployOnly) CleanPreviousVersion

func (d *DeployOnly) CleanPreviousVersion(config schemas.Config) error

CleanPreviousVersion cleans previous version of autoscaling group

func (*DeployOnly) Deploy

func (d *DeployOnly) Deploy(config schemas.Config) error

Deploy function

func (*DeployOnly) FinishAdditionalWork

func (d *DeployOnly) FinishAdditionalWork(config schemas.Config) error

FinishAdditionalWork processes additional work for the new deployment

func (*DeployOnly) GatherMetrics

func (d *DeployOnly) GatherMetrics(config schemas.Config) error

GatherMetrics gathers the whole metrics from deployer

func (*DeployOnly) GetDeployer

func (d *DeployOnly) GetDeployer() *Deployer

GetDeployer returns Deployer struct

func (*DeployOnly) HealthChecking

func (d *DeployOnly) HealthChecking(_ schemas.Config) error

HealthChecking does health checking for d.ue-green deployment

func (*DeployOnly) RunAPITest

func (d *DeployOnly) RunAPITest(config schemas.Config) error

RunAPITest tries to run API Test

func (*DeployOnly) TriggerLifecycleCallbacks

func (d *DeployOnly) TriggerLifecycleCallbacks(config schemas.Config) error

TriggerLifecycleCallbacks.cks runs lifecycle callbacks d.fore cleaning.

type Deployer

type Deployer struct {
	Mode              string
	AsgNames          map[string]string
	PrevAsgs          map[string][]string
	PrevInstances     map[string][]string
	PrevVersions      map[string][]int
	PrevInstanceCount map[string]schemas.Capacity
	SecurityGroup     map[string]*string
	LatestAsg         map[string]string
	Logger            *Logger.Logger
	Stack             schemas.Stack
	AwsConfig         schemas.AWSConfig
	APITestTemplate   *schemas.APITestTemplate
	AWSClients        []aws.Client
	LocalProvider     builder.UserdataProvider
	Slack             slack.Slack
	AppliedCapacity   *schemas.Capacity
	Collector         collector.Collector
	StepStatus        map[int64]bool
	DeploymentFlag    map[string]string
}

Deployer per stack

func InitDeploymentConfiguration

func InitDeploymentConfiguration(h *helper.DeployerHelper, awsClients []aws.Client) Deployer

InitDeploymentConfiguration returns initialized configurations for Deployer

func (*Deployer) CheckAutoscalingInstanceCount

func (d *Deployer) CheckAutoscalingInstanceCount(client aws.Client, asg string, desired int) (bool, error)

CheckAutoscalingInstanceCount checks instance count in the autoscaling group with desired value

func (*Deployer) CheckPrevious

func (d *Deployer) CheckPrevious(config schemas.Config) error

CheckPrevious checks if there is any previous version of autoscaling group

func (*Deployer) CheckTerminating

func (d *Deployer) CheckTerminating(client aws.Client, target string, disableMetrics bool) bool

CheckTerminating checks if all of instances are terminated well

func (*Deployer) CleanAutoscalingSet

func (d *Deployer) CleanAutoscalingSet(client aws.Client, target string) error

CleanAutoscalingSet cleans autoscaling group itself

func (*Deployer) CleanChecking

func (d *Deployer) CleanChecking(config schemas.Config) (bool, error)

CleanChecking checks if instances in previous autoscaling groups are terminated or not

func (*Deployer) CleanPreviousAutoScalingGroup

func (d *Deployer) CleanPreviousAutoScalingGroup(config schemas.Config) error

CleanPreviousAutoScalingGroup cleans previous version of autoscaling group

func (*Deployer) ClearResources

func (d *Deployer) ClearResources(client aws.Client, target string, disableMetrics bool) bool

ClearResources removes all resources of deployment and record metrics

func (*Deployer) CompareWithCurrentCapacity

func (d *Deployer) CompareWithCurrentCapacity(forceManifestCapacity bool, region string) schemas.Capacity

CompareWithCurrentCapacity compares capacity of manifest with the one in current deployment to adjust capacity in order to prevent sudden decrease of capacity which could impact current environment

func (*Deployer) DecideCapacity

func (d *Deployer) DecideCapacity(forceManifestCapacity, completeCanary bool, region string, prevAsgCount int, rollingUpdateInstanceCount int64) (schemas.Capacity, error)

DecideCapacity returns Applied Capacity for deployment

func (*Deployer) Deploy

func (d *Deployer) Deploy(config schemas.Config, region schemas.RegionConfig) error

Deploy is a basic deployment process for any deployment method

func (*Deployer) DescribeAutoScalingGroup

func (d *Deployer) DescribeAutoScalingGroup(asg, region string) (*autoscaling.Group, error)

DescribeAutoScalingGroup describes autoscaling group

func (*Deployer) DescribeInstances

func (d *Deployer) DescribeInstances(instanceIds []*string, region schemas.RegionConfig) ([]*ec2.Instance, error)

DescribeInstances describes instances

func (*Deployer) DescribeTargetGroup

func (d *Deployer) DescribeTargetGroup(targetGroup string, region string) (*elbv2.TargetGroup, error)

DescribeTargetGroups retrieves target group details

func (*Deployer) DoCommonAdditionalWork

func (d *Deployer) DoCommonAdditionalWork(config schemas.Config) error

DoCommonAdditionalWork does the common work regardless of replacement type

func (*Deployer) GatherMetrics

func (d *Deployer) GatherMetrics(client aws.Client, asg string) error

GatherMetrics gathers metrics of autoscaling group

func (*Deployer) GenerateAPIAttacker

func (d *Deployer) GenerateAPIAttacker(template schemas.APITestTemplate) (*APIAttacker, error)

GenerateAPIAttacker create API Attacker

func (*Deployer) GenerateTags

func (d *Deployer) GenerateTags(asgName, stack string, extraTags, ansibleExtraVars, region string) []*autoscaling.Tag

GenerateTags creates tag list for autoscaling group

func (*Deployer) GetStackName

func (d *Deployer) GetStackName() string

GetStackName returns name of stack

func (*Deployer) GetTargetGroupNames

func (d *Deployer) GetTargetGroupNames(region schemas.RegionConfig) []string

GetTargetGroupNames retrieves slice of target group name string

func (*Deployer) GetValidHostCount

func (d *Deployer) GetValidHostCount(targetHosts []aws.HealthcheckHost) int64

GetValidHostCount return the number of health host

func (*Deployer) HealthChecking

func (d *Deployer) HealthChecking(config schemas.Config) (bool, error)

HealthChecking does health check

func (*Deployer) Polling

func (d *Deployer) Polling(region schemas.RegionConfig, asg *autoscaling.Group, client aws.Client, forceManifestCapacity, isUpdate, downsizingUpdate bool) (bool, error)

Polling is polling healthy information from instance/target group

func (*Deployer) ReducePreviousAutoScalingGroupCapacity

func (d *Deployer) ReducePreviousAutoScalingGroupCapacity(region string, decreaseCnt int64) (bool, error)

ReducePreviousAutoScalingGroupCapacity cleans previous version of autoscaling group

func (*Deployer) ResizingAutoScalingGroup

func (d *Deployer) ResizingAutoScalingGroup(asg, region string, capacity schemas.Capacity) error

ResizingAutoScalingGroup sets autoscaling group instance count to desired value

func (*Deployer) ResizingAutoScalingGroupCount

func (d *Deployer) ResizingAutoScalingGroupCount(client aws.Client, asg string, count int64) error

ResizingAutoScalingGroupCount set autoscaling group instance count to 0

func (*Deployer) RunAPITest

func (d *Deployer) RunAPITest(config schemas.Config) error

RunAPITest tries to run API Test

func (*Deployer) RunLifecycleCallbacks

func (d *Deployer) RunLifecycleCallbacks(client aws.Client, region string) bool

RunLifecycleCallbacks runs commands before terminating.

func (*Deployer) SkipDeployStep

func (d *Deployer) SkipDeployStep()

SkipDeployStep skips deployment processes

func (*Deployer) StartGatheringMetrics

func (d *Deployer) StartGatheringMetrics(config schemas.Config) error

StartGatheringMetrics starts to gather the whole metrics from deployer

func (*Deployer) TriggerLifecycleCallbacks

func (d *Deployer) TriggerLifecycleCallbacks(config schemas.Config) error

TriggerLifecycleCallbacks runs lifecycle callbacks before cleaning.

type RollingUpdate

type RollingUpdate struct {
	PrevTargetGroups            map[string][]string
	TargetGroups                map[string][]*string
	PrevHealthCheckTargetGroups map[string]string
	LoadBalancer                map[string]string
	LBSecurityGroup             map[string]*string
	*Deployer
}

func NewRollingUpdate

func NewRollingUpdate(h *helper.DeployerHelper) *RollingUpdate

NewRollingUpdate creates new rolling-update deployment deployer

func (*RollingUpdate) CheckPreviousResources

func (r *RollingUpdate) CheckPreviousResources(config schemas.Config) error

CheckPreviousResources checks if there is any previous version of autoscaling group

func (*RollingUpdate) CleanChecking

func (r *RollingUpdate) CleanChecking(config schemas.Config) error

CleanChecking checks Termination status

func (*RollingUpdate) CleanPreviousVersion

func (r *RollingUpdate) CleanPreviousVersion(config schemas.Config) error

CleanPreviousVersion cleans previous version of autoscaling group or canary target group

func (*RollingUpdate) CompleteRollingUpdate

func (r *RollingUpdate) CompleteRollingUpdate(config schemas.Config, region schemas.RegionConfig) error

CompleteRollingUpdate processes the whole process of rolling update

func (*RollingUpdate) Deploy

func (r *RollingUpdate) Deploy(config schemas.Config) error

Deploy runs deployments with rolling update approach

func (*RollingUpdate) FinishAdditionalWork

func (r *RollingUpdate) FinishAdditionalWork(config schemas.Config) error

FinishAdditionalWork processes additional work for the new deployment

func (*RollingUpdate) GatherMetrics

func (r *RollingUpdate) GatherMetrics(config schemas.Config) error

GatherMetrics gathers the whole metrics from deployer

func (*RollingUpdate) GetDeployer

func (r *RollingUpdate) GetDeployer() *Deployer

GetDeployer returns canary deployer

func (*RollingUpdate) HealthChecking

func (r *RollingUpdate) HealthChecking(config schemas.Config) error

HealthChecking does health checking for canary deployment

func (*RollingUpdate) RunAPITest

func (r *RollingUpdate) RunAPITest(config schemas.Config) error

RunAPITest tries to run API Test

func (*RollingUpdate) TriggerLifecycleCallbacks

func (r *RollingUpdate) TriggerLifecycleCallbacks(config schemas.Config) error

TriggerLifecycleCallbacks runs lifecycle callbacks before cleaning.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL