GithubHelp home page GithubHelp logo

dbritto-dev / udacity-cloud-devops-engineer-capstone Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.49 MB

Capstone Project for Cloud DevOps Engineer on Udacity

Makefile 7.31% Dockerfile 13.39% Python 79.30%
capstone udacity-devops-nanodegree kubernetes pipeline eks jenkins eksctl flask covid19 scraped-data

udacity-cloud-devops-engineer-capstone's Introduction

Project Overview

This application simplies the access to the covid 19 stats of the world (stats for each country). This application is used to implement all the knowledge acquired on the Cloud DevOps Engineer Nano Degree on Udacity. The app has a simple api with two endpoints, the app is built it on top of Python using Flask and BeautifulSoup 4 (to scrape the data).

API URL: <your-api-url> (see the Verifying section to get the url of your api).

Endpoints Path Description
GET / Returns a Hello World! message with the current state of the app (blue or green).
GET /world-stats Returns covid stats of the world.

PROJECT STRUCTURE

File Name                Description        
├── code/ This directory contains the Python Flask app and Tests
  ├── capstone/ Python Flask App.
  ├── tests/ Tests for the Python Flask App.
  ├── .coveragerc Python Coverage configuration file.
  ├── requirements-ci.txt Python dependencies file for Continuous Integration (CI).
  ├── requirements-dev.txt Python dependencies file for development.
  ├── requirements.txt Python dependencies file for production.
  ├── run.py Python script to run the application.
  └── tox.ini Flask8 configuration file.
├── infra/ This directory contains the files for docker and kubernetes.
  ├── docker/ Docker files for blue and green images.
  ├── k8s/ Kubernetes files for blue and green deployments.
  └── server.yaml Template to create the cluster on Amazon EKS using EKSCTL.
├── nginx/ This directory contains the files for a custom NGINX configuration.
├── screenshots/ This directory contains the screenshots for the project validation.
├── .editorconfig Configuration file for editorconfig.
├── .gitignore Configuration file for gitignore.
├── Jenkinsfile Configuration file for Jenkins Pipelines.
├── Makefile Set of custom scripts.
├── README.md Description of the app.
└── TODO.md Project TODO.

Pre-requisites

Note: Jenkins needs Java to run. To install Java for jenkins run this command: sudo apt install default-jdk -y (only Debian distros)

Setup

1. Create the Cluster

To create a cluster you can use the following command.

$ eksctl create cluster -f ./infra/eks/cluster.yaml

Note: You can create the cluster manually following this guide: https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html

2. Create a Kubernetes config for Amazon EKS

To create/update a Kubernetes config (kubeconfig) you can use following command.

$ aws eks --region us-east-1 update-kubeconfig --name capstone-cluster

Note: Read more about kubeconfig files for EKS on: https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html

3. Configure Jenkins

Plugins

Credentials

  • Docker (Steps):
    • ➡️ Jenkins (Dashboard)
    • ➡️ Manage Jenkins
    • ➡️ Configure System
    • ➡️ Declarative Pipeline (Docker)
  • Kubernetes Config File (Steps):
    • ➡️ Jenkins (Dashboard)
    • ➡️ Job (github repo)
    • ➡️ Credentials
    • ➡️ Store scoped to <github-repo>
    • ➡️ Global
    • ➡️ Add credentials
      • Kind: Secret Text
      • ID: k8s-confige-file
      • Secret: /path/to/your/kubeconfig-file (absolute paths) e.g: /home/ubuntu/.kube/kubeconfig
  • AWS (Steps):
    • ➡️ Jenkins (Dashboard)
    • ➡️ Job (github repo)
    • ➡️ Credentials
    • ➡️ Store scoped to <github-repo>
    • ➡️ Global
    • ➡️ Add credentials
      • Kind: AWS Credentials
      • ID: aws-creds
      • Fill the other fields.

Pipelines

To create a pipeline using BlueOcean follow this guide: https://www.jenkins.io/doc/book/blueocean/creating-pipelines/

Deploying

Automate deploys

You can trigger the deployments just pushing update the right branch. If you want to a blue deployment push your changes to the blue branch.

Manual deploys

You can trigger manual deploy using the following command:

$ kubectl apply -f ./infra/k8s/deployments/blue.yaml
$ kubectl apply -f ./infra/k8s/services/blue.yaml

or

$ kubectl apply -f ./infra/k8s/deployments/blue.yaml -f ./infra/k8s/services/blue.yaml

Note: This step require to access to your ec2 instance before. Check the Verifying section to get help.

Verifying

1. Connect to the EC2 instance using ssh

To connect to your EC2 instance follow this guide: https://docs.aws.amazon.com/quickstarts/latest/vmlaunch/step-2-connect-to-instance.html

2. Get the link to the appplication

To get the external ip of our service you can use the following command:

$ kubectl get services -l app=capstone --output jsonpath='{.items[].status.loadBalancer.ingress[].hostname}'

With the link you can access to the app. If all is working yo can see a message like this:

{"message":"Hello GREEN APP!"}

or

{"message":"Hello BLUE APP!"}

Thanks to

A big thanks to

  • Udacity
  • Raul Hugo @RaulHugo

udacity-cloud-devops-engineer-capstone's People

Contributors

dbritto-dev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.