Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deployment configuration spec for Lambda application #667

Merged
merged 1 commit into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/en/docs/examples/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ https://github.com/pipe-cd/examples
|-----------------------------------------------------------------------------|-------------|
| [simple](https://github.com/pipe-cd/examples/tree/master/lambda/simple) | Quick sync by rolling out the new version and switching all traffic to it. |
| [canary](https://github.com/pipe-cd/examples/tree/master/lambda/canary) | Deployment pipeline with canary strategy. |
| [bluegreen](https://github.com/pipe-cd/examples/tree/master/lambda/bluegreen) | Deployment pipeline with bluegreen strategy. |

| [analysis](https://github.com/pipe-cd/examples/tree/master/lambda/analysis) | Deployment pipeline that contains an analysis stage. |
| [remote-git](https://github.com/pipe-cd/examples/tree/master/kubernetes/remote-git) | Deploy the lambda code sourced from another Git repository. |
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,12 @@ spec:
| Field | Type | Description | Required |
|-|-|-|-|

### CloudRunTrafficRoutingStageOptions

| Field | Type | Description | Required |
|-|-|-|-|

### LambdaCanaryRolloutStageOptions

| Field | Type | Description | Required |
|-|-|-|-|

### LambdaTrafficRoutingStageOptions
### LambdaPromoteStageOptions

| Field | Type | Description | Required |
|-|-|-|-|
Expand Down
3 changes: 2 additions & 1 deletion docs/content/en/docs/user-guide/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ https://github.com/pipe-cd/examples
|-----------------------------------------------------------------------------|-------------|
| [simple](https://github.com/pipe-cd/examples/tree/master/lambda/simple) | Quick sync by rolling out the new version and switching all traffic to it. |
| [canary](https://github.com/pipe-cd/examples/tree/master/lambda/canary) | Deployment pipeline with canary strategy. |
| [bluegreen](https://github.com/pipe-cd/examples/tree/master/lambda/bluegreen) | Deployment pipeline with bluegreen strategy. |
| [analysis](https://github.com/pipe-cd/examples/tree/master/lambda/analysis) | Deployment pipeline that contains an analysis stage. |
| [remote-git](https://github.com/pipe-cd/examples/tree/master/kubernetes/remote-git) | Deploy the lambda code sourced from another Git repository. |

4 changes: 2 additions & 2 deletions examples/README.remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ A repository contains some examples for PipeCD.
|-----------------------------------------------------------------------------|-------------|
| [simple](https://github.com/pipe-cd/examples/tree/master/lambda/simple) | Quick sync by rolling out the new version and switching all traffic to it. |
| [canary](https://github.com/pipe-cd/examples/tree/master/lambda/canary) | Deployment pipeline with canary strategy. |
| [bluegreen](https://github.com/pipe-cd/examples/tree/master/lambda/bluegreen) | Deployment pipeline with bluegreen strategy. |

| [analysis](https://github.com/pipe-cd/examples/tree/master/lambda/analysis) | Deployment pipeline that contains an analysis stage. |
| [remote-git](https://github.com/pipe-cd/examples/tree/master/kubernetes/remote-git) | Deploy the lambda code sourced from another Git repository. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
git: git@github.com:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
# Lambda code sourced from the same Git repository.
path: lambdas/helloworld
pipeline:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: LAMBDA_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: LAMBDA_TRAFFIC_ROUTING
# Promote new version to receive amount of traffic.
- name: LAMBDA_PROMOTE
with:
canary: 100
percent: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
- name: ANALYSIS
# Promote new version to receive all traffic.
- name: LAMBDA_PROMOTE
with:
percent: 100
28 changes: 11 additions & 17 deletions examples/lambda/canary/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@ apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
git: git@github.com:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
# Lambda code sourced from the same Git repository.
path: lambdas/helloworld
pipeline:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: LAMBDA_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: LAMBDA_TRAFFIC_ROUTING
# Promote new version to receive amount of traffic.
- name: LAMBDA_PROMOTE
with:
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
- name: ANALYSIS
# Change the traffic routing state where
# thre new version will receive 100% of the traffic.
- name: LAMBDA_TRAFFIC_ROUTING
percent: 10
- name: LAMBDA_PROMOTE
with:
canary: 100
percent: 50
# Promote new version to receive all traffic.
- name: LAMBDA_PROMOTE
with:
percent: 100
10 changes: 10 additions & 0 deletions examples/lambda/remote-git/.pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Quick sync by rolling out the new version and switching all traffic to it.
# https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html
apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Lambda code sourced from another Git repository.
git: git@github.com:org/source-repo.git
path: lambdas/helloworld
ref: v1.0.0
7 changes: 2 additions & 5 deletions examples/lambda/simple/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
# If the source code is inside the same repository "git" and "ref" can be omitted.
git: git@github.com:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
# Lambda code sourced from the same Git repository.
path: lambdas/helloworld
12 changes: 6 additions & 6 deletions pkg/config/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ type PipelineStage struct {
CloudRunSyncStageOptions *CloudRunSyncStageOptions
CloudRunPromoteStageOptions *CloudRunPromoteStageOptions

LambdaSyncStageOptions *LambdaSyncStageOptions
LambdaCanaryRolloutStageOptions *LambdaCanaryRolloutStageOptions
LambdaTrafficRoutingStageOptions *LambdaTrafficRoutingStageOptions
LambdaSyncStageOptions *LambdaSyncStageOptions
LambdaCanaryRolloutStageOptions *LambdaCanaryRolloutStageOptions
LambdaPromoteStageOptions *LambdaPromoteStageOptions
}

type genericPipelineStage struct {
Expand Down Expand Up @@ -175,10 +175,10 @@ func (s *PipelineStage) UnmarshalJSON(data []byte) error {
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.LambdaCanaryRolloutStageOptions)
}
case model.StageLambdaTrafficRouting:
s.LambdaTrafficRoutingStageOptions = &LambdaTrafficRoutingStageOptions{}
case model.StageLambdaPromote:
s.LambdaPromoteStageOptions = &LambdaPromoteStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.LambdaTrafficRoutingStageOptions)
err = json.Unmarshal(gs.With, s.LambdaPromoteStageOptions)
}

default:
Expand Down
26 changes: 4 additions & 22 deletions pkg/config/deployment_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,11 @@ type LambdaDeploymentInput struct {
type LambdaSyncStageOptions struct {
}

// LambdaCanaryRolloutStageOptions contains all configurable values for a CLOUDRUN_PROMOTE stage.
// LambdaCanaryRolloutStageOptions contains all configurable values for a CLOUDRUN_CANARY_ROLLOUT stage.
type LambdaCanaryRolloutStageOptions struct {
}

// LambdaTrafficRoutingStageOptions contains all configurable values for a CLOUDRUN_TRAFFIC_ROUTING stage.
type LambdaTrafficRoutingStageOptions struct {
// Which variant should receive all traffic.
// This can be either "primary" or "canary".
All string `json:"all"`
// The percentage of traffic should be routed to PRIMARY variant.
Primary int `json:"primary"`
// The percentage of traffic should be routed to CANARY variant.
Canary int `json:"canary"`
}

func (opts LambdaTrafficRoutingStageOptions) Percentages() (primary, canary int) {
switch opts.All {
case "primary":
primary = 100
return
case "canary":
canary = 100
return
}
return opts.Primary, opts.Canary
// LambdaPromoteStageOptions contains all configurable values for a CLOUDRUN_PROMOTE stage.
type LambdaPromoteStageOptions struct {
Percent int `json:"percent"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
- name: CLOUDRUN_PROMOTE
with:
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/testdata/application/cloudrun-app-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
- name: CLOUDRUN_PROMOTE
with:
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
Expand All @@ -21,6 +21,6 @@ spec:
- name: ANALYSIS
# Change the traffic routing state where
# thre new version will receive 100% of the traffic.
- name: CLOUDRUN_TRAFFIC_ROUTING
- name: CLOUDRUN_PROMOTE
with:
canary: 100
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: LAMBDA_TRAFFIC_ROUTING
- name: LAMBDA_PROMOTE
with:
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/testdata/application/lambda-app-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: LAMBDA_TRAFFIC_ROUTING
- name: LAMBDA_PROMOTE
with:
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
Expand All @@ -25,6 +25,6 @@ spec:
- name: ANALYSIS
# Change the traffic routing state where
# thre new version will receive 100% of the traffic.
- name: LAMBDA_TRAFFIC_ROUTING
- name: LAMBDA_PROMOTE
with:
canary: 100
5 changes: 2 additions & 3 deletions pkg/model/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ const (
// StageLambdaCanaryRollout represents the state where
// the workloads of the new version has been rolled out.
StageLambdaCanaryRollout Stage = "LAMBDA_CANARY_ROLLOUT"
// StageLambdaTrafficRouting represents the state where the traffic to application
// should be splitted as the specified percentage to previous version and new version.
StageLambdaTrafficRouting Stage = "LAMBDA_TRAFFIC_ROUTING"
// StageLambdaPromote prmotes the new version to receive amount of traffic.
StageLambdaPromote Stage = "LAMBDA_PROMOTE"

// StageRollback represents a state where
// the all temporarily created stages will be reverted to
Expand Down