GithubHelp home page GithubHelp logo

mrtam-node / cloud-devops-engineer-capstone-project Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miguelangelnieto/cloud-devops-engineer-capstone-project

0.0 0.0 0.0 797 KB

Final project of the DevOps Udacity Nanodegree

Shell 0.55% Python 5.99% CSS 69.80% HTML 23.47% Dockerfile 0.19%

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

Cloud DevOps Engineer Capstone Project

Final project of the DevOps Udacity Nanodegree

Introduction

In this project I will apply the skills and knowledge which were developed throughout the Cloud DevOps Nanodegree program. These include:

  • Working in AWS
  • Using Jenkins to implement Continuous Integration and Continuous Deployment
  • Building pipelines
  • Working with Ansible and CloudFormation to deploy clusters
  • Building Kubernetes clusters
  • Building Docker containers in pipelines

Application

The application is my own Python script that generates HTML pages from Markdown files using a template. I use it to generate the blog posts on https://blog.miguelangelnieto.net. In this project there is one single page, named index.md that will be used as an example:

python3 html_generator.py 

By default it will convert all Markdown files to HTML.

Kubernetes Cluster

Cloudformation is used to deploy the Kubernetes Cluster and the NodeGroup. The code is in cloudformation directory. It is divided in two stacks, one for the network (network.yml) and a second one for the cluster itself (EKS.yml).

There are two scripts to create and update the stacks. For example, to create both stacks:

./stack-create.sh capstone-stack network.yml network-parameters.json
./stack-create.sh capstone-eks EKS.yml EKS-parameters.json

This will create the stack in the following order:

  1. VPC in eu-west-1.
  2. Internet Gateway attached to the VPC.
  3. Two public subnets in different AZs.
  4. Public route table associated with the two public subnets.
  5. Security group for the cluster.
  6. Kubernetes cluster.
  7. Kubernetes node group.

The node group is created in EC2:

OK Lint

Jenkins Pipeline

I am using a CI/CD pipeline on a rolling deployment. On each new HTML generated, the docker image is updated, pushed to AWS and the Kubernetes pods are rolled out so they restart with the new image from the repository. There is a load balancer before the exposed 80 TCP ports to avoid having downtime. These are the steps in more detail:

Jenkins Pipeline

  1. Python Req.

The script's Python requirements are installed. They include markdown, pylint and beautifulsoup4.

pip3 install -r requirements.txt
  1. Python Lint

Check the script's code with pylint.

pylint --disable=W0311 html_generator.py

This is the output when the steps fails:

Failed Lint

And this is the output when it passes:

OK Lint

  1. Generage HTML

The HTML pages are generated.

python3 html_generator.py
  1. Build & Push

The docker image is build using the Dockerfile and the image is pushed to Amazon Elastic Container Registry.

aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 628641662978.dkr.ecr.eu-west-1.amazonaws.com/capstone
docker -H=tcp://localhost:2375 build -t capstone .
docker -H=tcp://localhost:2375 tag capstone:latest 628641662978.dkr.ecr.eu-west-1.amazonaws.com/capstone:latest
docker -H=tcp://localhost:2375 push 628641662978.dkr.ecr.eu-west-1.amazonaws.com/capstone:latest
  1. Docker Container

A Docker Container is started to test if there is any problem using the image.

docker -H=tcp://localhost:2375 container run 628641662978.dkr.ecr.eu-west-1.amazonaws.com/capstone:latest
  1. Deployment

The Kubernetes pods are deployed using the pushed image. This is a no-op if the deployment files have not changed.

kubectl apply -f deployment.yml
kubectl apply -f loadbalancer.yml
  1. Rollout Deployment

Rollout the pods to use the new pushed image.

kubectl rollout restart deployment/webserver

View the public web page

Finally, enter the public DNS record in the web browser to access the page.

$ kubectl get deployment
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
webserver   1/1     1            1           7m30s
$ kubectl get service
NAME           TYPE           CLUSTER-IP    EXTERNAL-IP                                                              PORT(S)        AGE
kubernetes     ClusterIP      172.20.0.1    <none>                                                                   443/TCP        19m
loadbalancer   LoadBalancer   172.20.75.5   a7d6a3407345144acbc7e1c2c7009a4c-669847975.eu-west-1.elb.amazonaws.com   80:31022/TCP   7m36s

http://a7d6a3407345144acbc7e1c2c7009a4c-669847975.eu-west-1.elb.amazonaws.com

Webpage

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

Contributors

miguelangelnieto avatar mrtam-node 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.