Application
- Logical container for revision, deployment configuration and deployment groups (target instances)
- Has Name
- e.g. "All", "PaymentService"
Application Revision
- Archive containing
- Source files, binary objects, etc.
- AppSpec file
- Storage (Repository)
- S3 - identified by S3 object Key/ETAG
- command: "aws deploy push"
- GitHub - commitId
- BitBucket
- S3 - identified by S3 object Key/ETAG
- Target Revision
- Most recent revision
- Not every application revision must be deployed
AppSpec
- YAML file
- Maps source files to the destination
- Specifies custom permissions
- Specify scripts to be run at various stages
- Series of lifecycle events (hooks)
- Agent retrieves the lists of scripts, executes them and logs output
- At the root directory
- Maps sources files to their destination on disk
- Defines hook scripts
- Template
- os [linux, windows]
- files
- permissions (linux only)
- hooks
- Specify: location, timeout, runas
- types
- ApplicationStop
- BeforeInstall
- AfterInstall
- ApplicationStart
- ValidateService
Deployment Group
- Individual instances
- Individually tagged (union of all tags)
- On-premise
- AutoScaling Group
- deployment triggered when new instance is launched
- do not associate multiple Deployment Groups with the same ASG
- multiple deployments will be started at once on the same instance
Security
- IAM Instance Profile
- agent can access S3/GitHub
- Service Role
- AWS CodeDeploy can read instance tags/ASG groups
Deployment Configuration
- Predefined
- One at a time
- Half at a time
- All at once
- MinimumHealthyHosts
- healthy hosts must be available during deployment
- determine if overall deployment suceeded
- e.g. Fleet = 9, MinimumHealthyHosts = 6, Deploys to max 3 at a time
- specified as Absolute or Percentage
CodeDeploy Agent
- Runs on machine
- Configuration
- log_aws_wire = detailed wire logs
- wait_between_runs = default 1 second
On-premise deployment
- Create IAM user for each instance (instead of instance profile)
- Register instance with CodeDeploy (instead of Tag)
- Cannot participate in ELB/ASG
- Additional cost
Health
- CodeDeploy determines the health status
- Factors
- RevisionHealth
- Current - revision matches last successful deployment
- Old - revision matches old version
- Unknown - revision not installed successfuly
- InstanceHealth
- Healthy - was last deployment successful
- Unhealthy - deployment failure, or not attempted
- RevisionHealth
- It does not have any healthcheck (like ELB)
- The ValidateApplication can be used for InstanceHealth
- fail deployment if fails
- Health status in DeploymentGroup is monitored
- Deployment fails if healthy instances count < MinimumHealthyHosts
- Deployment Order
- InstanceHealth: Unhealthy
- RevisionHealth: Unknown
- RevisionHealth: Old
- RevisionHealth: Current
Misc
- Performs AZ striping to minimize risk
- Based on Amazon internal tool: Apollo
Events
- Lifecycle events
- DeploymentStart
- DeploymentSuccess
- DeploymentFailure
- InstanceStart
- InstanceSuccess
- InstanceFailure
- Target
- SNS
No comments:
Post a Comment