Continuous Deployment to Kubernetes using AWS CodeCommit, AWS CodeBuild, AWS CodePipeline and AWS ECR

This blog describes steps on how to create a complete, end to end continuous deployment pipeline with Amazon ECR and AWS CodePipeline. Developers will stay focused on developing code in this environment, and project managers can be confident the latest developments are always introduced without thinking about how it is deployed.

Application containerization is the popular move for both enterprises and digital native business. The preferred orchestration platform seems to be Kubernetes(K8s). K8s popularity can very well be observed from the cloud native service support being made available. One of the major opportunities while developing a containerized application is ability to bring in the automation via DevOps (CI / CD) especially those leveraging Cloud Native services. In the software development process, AWS development tools help to achieve seamless deployments from a scheduled release to a continuous integration and  continuous delivery.

By Leveraging AWS  continuous deployment services, it automatically takes your code from a source code repository to the production environment in a Kubernetes cluster with a minimal user intervention.

Build a full CI / CD pipeline that will be installed in the Kubernetes cluster and the Github repo to set up the application image with all the scripts used for this deployment. This is a basic CI/CD flow to demonstrate how to deploy a simple application when developers commit the source code.

  1. The developer will commit code on CodeCommit/Github.
  2. The CodePipeline will poll source code when there is any changes.
  3. The CodeBuild will build a docker image and push the image to ECR.

Who should use this?

This will assist developers and the operations team in understanding how their application can be migrated and implementing changes to the deployment environment with minimal intervention but with consistency.

Key benefits:

  • Easily deploy the application with consistent turn-around time.
  • Codecommit automatically encrypts all the files in transit and at-rest.
  • Provides private git repositories for developers to use.

Walk through of high level steps,

Prerequisites:

The Git repository instructions covers the Pre-requisites including IAM service roles, client server setup and codecommit repositories setup.

AWS CodeCommit, CodeBuild, CodePipeline and ECR:

AWS CodeCommit is a secure, scalable, managed source control service that hosts private Git repositories. It will automatically encrypt your files in transit and at-rest.

AWS CodeBuild is a fully managed build service in the cloud. It is referred as a Continuous Integration tool. It will get the source code and runs it into a container for us from the source provider.

AWS CodePipeline is a fully managed deployment pipeline service. It is a CD pipeline orchestrator. We don’t need to give scripts to run instead give it as a sequence of actions, which are links to other services.

AWS ECR is AWS managed docker registry service. We can use the docker CLIs to push, pull and manage images. It will transfer the container images over HTTPs and automatically encrypt the images at-rest.

Kubernetes Cluster on EC2:

Deploying K8s on EC2 instance leveraging Kops. Once the Cluster is up and running, application will be deployed.

Next Steps:

Now that you know how quick and easy it is to automate the build and deployment process, you may go ahead and implement it yourself. There are also ways you can introduce “Automatic Code Review” and “Automatic regression / functional testing” as part of the flow using third party services / tools which will make this a complete CI/CD pipeline. All this are possible with few configurations and commands in place. Your feedback are most welcome. Speak to our cloud consultants for more in-depth details.

 

Written by, Geetha PandiyanUmashankar N

 

Sharing is caring!