Skip to content

Latest commit

 

History

History
196 lines (107 loc) · 8.74 KB

workshop7.md

File metadata and controls

196 lines (107 loc) · 8.74 KB

S-DOEA - Workshop 7 - End to end DevOps Engineering and Automation

AWS Codestar with Python Flask Project

At the end of this tutorial, you will be able to push your code changes to Github and run it in an EC2 instance deployed AWS CodeBuild.

All of AWS services in this tutorial should be in the same region Singapore or Sydney (ap-southeast-1 or ap-southeast-2).

Pre-requisites

  • Team workshop
  • Github Account
  • AWS Account
  • AWS Region : Singapore/Sydney (ap-southeast-1/2)
  • AWS EC2 Key Pair. Follow this tutorial and take note of your Key Pair. There is no need for us to ssh into a machine here so we can skip the chmod step in the guide.

Step by step guide - basic CodeStar setup

  1. Open AWS Codestar.

  2. Click "Create a new project".

  3. Choose Python (Flask) Web server / Amazon EC2.

  4. Enter your Project Details.

  5. Choose GitHub as your repository.

  6. Click "Connect to GitHub" button.

    CodeStar Project Details

  7. Enter your GitHub reporitory details. Select repo as public.

    GitHub repository details

  8. After reviewing the project details, click "Create Project". This will automatically create the GitHub repository for you. You can visit GitHub afterwards to see your repository.

  9. Choose the keypair that you have created in the Pre-Requisites as you Key Pair.

  10. Click "Next" button, you will be redirected to the Project setup page. Try to refresh the page to see if the project setup has finished.

    Project loading

  11. Capture screenshot of the successful build, save it along as part of your submission.

  12. In the upper right side of the Project setup page, the application endpoint will show up when the deployment has finished loading. You can check the deployment status in the Continuous deployment section.

  13. Click the Application Endpoint when it is ready and you should be able to see the JSON response of your Flask API.

  14. Update your helloworld/application.py file to change your application's output using GitHub's web interface. Observe the deployment pipeline and refresh your Application Endpoint. You can change the following line under the get() method:

    return Response(json.dumps({'Output': 'Hello World from Codestar'}), mimetype='application/json', status=200)
    
  15. Capture screenshot of the failed build, save it along as part of your submission.

AWS Codestar integrate with Jenkins using Spring Boot Project template

  1. Repeat the above steps 1 - 11, select 'Java Spring' Web service on EC2 when creating the new codestar template wizard.

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

  1. Logon to your own AWS Jenkins as below:-
  • Your own AWS Jenkins Server

    • url : http://<your AWS Jenkins server's public ip address>/jenkins/
  • Install all the required plugins. Lecturer will provide the plugins pdf in the class.

  • Setup the system configuration according to the screenshot

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

  1. Create a new freestyle project item with following naming convention 'aws_javaspringboot_group name>'

  2. Configure the jenkins job as below

    CodeStar Project Details

    CodeStar Project Details

    CodeStar Project Details

  • Configure SCM and the build schedule trigger
  • Create 5 shell execute under the pre jenkins action

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

  1. Create a Dockerfile on the root of the project directory for this Spring Boot project. *Hint shown during lecturer day3.
FROM tomcat:latest

ADD target/ROOT.war /usr/local/tomcat/webapps/

EXPOSE 8080

CMD ["catalina.sh", "run"]


  1. Commit the Dockefile into your github repository.

  2. Capture screenshot of the successful build, save it along as part of your submission.

  3. Open your preferred editor and access the Spring Boot project. Modify the Spring Boot test case located in the namespace com.aws.codestar.projecttemplates.controller.HelloWorldControllerTest. Update the EXPECTED_RESPONSE_VALUE to say "Hello AWS CodeStar!!".

  4. Commit your codes to the github and watch how the build will fail.

  5. Capture screenshot of the failed build, save it along as part of your submission.

  6. Stabilize the test case before dockerized the app. Revert back the changes back to a successful build.

  7. Install Docker binaries on the jenkins server. (Workshop4)

  8. Set up the pre-build step in your Jenkins configuration to push the project's image to DockerHub. Use your DockerHub username as the prefix for the image tag, and provide DockerHub credentials. If you face permission issues, ensure that the Jenkins Unix user has the necessary Docker permissions. Additionally, perform a Docker login on the terminal switching to jenkins username before pushing the image to Docker Hub.

$ sudo usermod -aG docker jenkins
$ sudo usermod -aG docker bitnami
  
  1. Restart the EC2 jenkins instance

  2. Perform dockerlogin on the terminal under the jenkins username for the publication of the image to the hub

$ sudo su - jenkins
$ docker login

CodeStar Project Details

CodeStar Project Details

CodeStar Project Details

  1. Capture screenshot of the successful docker build and also the image is being store on the dockerhub repo, save it along as part of your submission.

CodeStar Project Details

  1. Try accessing the app via the end point created from the CodeStar dashboard.

Design and proposed CI CD pipeline for StoolViriiDetect Pte Ltd COVID19 - Internet of Things Project.

To detect covid19 cluster as early as possible, SG GovHighTech recently awarded StoolViriiDetect Pte Ltd the project to use their stool detection sensor solution in every residential area islandwide. The collected data should be sent to the Health Authority for analysis twice a day via a secure cloud channel. Kindly proposed an end to end CI CD pipeline for this project.

Things that the team should consider as below:-

  • Public Web App and API with a geolocation-based map showing a possible cluster
  • Private Web App with a map showing possible cluster and additional info
  • Integrated with the trace together mobile app to notify users that a potential new cluster. (Near to realtime)
  • Live update (firmware) to all the deployed sensors
  • Name all the technological stacks in terms of DevOps and implementation of your proposal.
  • The solution must be regional within the country. (Areas)

https://www.youtube.com/watch?v=XeFOpSNgSGk

https://www.youtube.com/watch?v=nN9d_bLE-vM&t=127s