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

CDK BlueGreen Deployment Codepipeline Pattern #181

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Howlla
Copy link
Contributor

@Howlla Howlla commented Dec 23, 2024

Issue #, if available:

Description of changes: Created a new pattern that supports 2 versions of EKS clusters i.e. blue and green simultaneously running. The switching from Blue to Green and vice-versa is done by updating the DNS record which requires manual approval in codepipeline.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@shapirov103 shapirov103 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a doc page under docs/patterns with the description of the pattern and instructions to launch. It seems I won't be able to validate just yet because of the hosted zone (unless we create it in the partner account).

errorHandler(app, "Blue Green cluster pattern is not setup. It may be due to missing secrets: ", error);
});

// import { configureApp, errorHandler } from '../lib/common/construct-utils';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove commented code. applies elsewhere.

envName: string;
}

class DnsStack extends cdk.Stack {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments on top, explain the purpose for this stack

import * as blueprints from '@aws-quickstart/eks-blueprints';


export default class MultiClusterBuilderConstruct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes it multi-cluster? Seems like it create a common blueprint. General approach on using this is using a function for example. Here is code example, mostly pseudo:

const clusterBlueprint = buildCommonBlueprint();

const blueClusterBlueprint = clusterBlueprint.clone();  // if you plan to customize, like adding additional addons, change providers
const greenClusterBlueprint = blueClusterBlueprint.clone();  // if you plan to customize

You can even inline the function. Having a separate class maybe an overkill - does not buy us much. Maybe keep the file, like common-builder.ts and put one builder function in it.

stackBuilder : blueprintBlue.clone(region),
// stageProps: {
// post: [
// new ShellStep("Validate App", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why validation is commented out? did it work?

// }
})

const blueprintGreen = blueprintBuilder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why version and cluster provider are here and not in the blueprint?

const stagesEks : blueprints.StackStage[] = [];

const blueprintBuilder = new MultiClusterBuilderConstruct().create(scope, accountID, region);
const blueprintBlue = blueprintBuilder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why version and cluster provider are here and not in the common blueprint?

})
const stagesDns : blueprints.StackStage[] = [];

const prodEnv = clusterBNameSuffix;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's say switch worked and moved DNS target to green. Now I have blue/green, Route53 points to green. What happens on the next iteration, when customer upgrades clusters to 1.31 and needs to engage blue/green again. Do you change the name of prodEnv?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants