To achieve continuous deployment on AWS cluster through kubernetes we have to undertake the following tasks

  • Make an environment for continuous deployment
  • Create Jenkins job for CD

First of all we will discuss about how to make an environment for continuous deployment. Before creating a cluster on AWS EC2 through kubernetes, we need to install some software in the client machine. The client machine could be an EC2 instance or desktop.  We assume that our client machine is EC2 instance.

These are the software we need to install on client machine:

  1. Java 8
  2. Maven 3.x
  3. aws-cli
  4. Docker.
  5. Jenkins
  6. Git

Now connect the EC2 instance through command line and change user to Jenkins. To connect EC2 instance, use the given command from the command line.


Change user to Jenkins. A Jenkins user should have access to all the above software.

Following are the Steps to Launch the Kubernetes Cluster on EC2:

A. Create AWS profile.

The command is given below for creating AWS profile


B. Now export AWS profile


C. Download kubernetes version 1.5

After unzipping the downloaded zip file, we get a kubernetes folder, which contains all the default configuration file for launching cluster on AWS, also we can override these configurations.

The default setting is available in the location /kubernetes/cluster/aws/ Here are some configurations which are overridden.

A better way to export is to keep this configuration into “.bashrc” file.


D. Start and stop cluster

Go to the given location to get script for start and stop /kubernetes/cluster/

Here you will get and for start and stop respectively.

Also we can automate this to create a Jenkins job.

The next important thing is to create a Jenkins job for continuous deployment. So let’s consider an example of spring boot microservice to deploy on AWS cluster.

Assume a spring microservice has the following files which are mandatory for creating a Jenkins job.

  • Dockerfile : This file is use for creating Docker container.
  • Jenkinsfile: It has defined some steps on how Jenkins must perform a  task in order to complete a job.

Following are the tasks performed which are contained in the Jenkinsfile

  1. Clone  the workspace
  2. Build project with running Junit test cases.
  3. Create an docker image
  4. Push docker image to docker registry (docker hub)
  5. Execute kubectl command for deploy docker image to aws cluster.

Jenkinsfile code example.