Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBA_Docker_Kubernetes #6

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CI_CD_diagram.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3.7
COPY . .
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["python","web.py"]
92 changes: 22 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,22 @@
# SBA Kubernetes Cluster
* **Objective** - Create a CI/CD Pipeline that builds an image from github and deploys it to a kubernetes cluster
* **Purpose** - To demonstrate container orchestration skillset



## Software Used in This Project
* Git CLI
* Docker
* minikube
* kubectl
* Python
* Flask
* Jenkins

## Instructions
* Fork and clone this project locally.
* Create a respective `requirements.txt` to download any `pip` dependencies for this python project.
* Ensure you `push` the newly created file: `requirements.txt`
* Create a `Dockerfile` to build the image. Push it to github
* Build the image
* Push image to one of your repos on [Dockerhub](https://hub.docker.com/).
* Create a `kubernetes.yml` which will pull the aforementioned Dockerhub image and create 3 running copies of it.
* Use the `kubernetes.yml` to launch your application. Push this file to your github repo as well. If possible have jenkins start the app by this method.
* Write and run a script to determine the state of your kubernetes cluster including the information about the services, pods, nodes, ip addresses, etc.
* upload script to github `kubernetes-cluster-information.sh`
* run script and redirect the output of the `kuberenetes-cluster-information.sh` to `kuberenetes-cluster-information-output`
* push the script output to your github repo


### How to Download

#### Part 1 - Forking the Project
* To _fork_ the project, click the `Fork` button located at the top right of the project.


#### Part 2 - Navigating to _forked_ Repository
* Navigate to your github profile to find the _newly forked repository_.
* Copy the URL of the project to the clipboard.

#### Part 3 - Cloning _forked_ repository
* Clone the repository from **your account** into the directory where you keep projects e.g. ~/projects
* clone the project by executing the following command:
* `git clone https://github.com/MYUSERNAME/NAMEOFPROJECT`

## How to run this
* Upon executing `python web.py`, navigate to `localhost:8080` to view the webpage.

<img src="./VIEWME.gif">


## Grading SBA (1100 pts total)
Points Breakdown

* 150 pushed a requirements.txt file to their repo
* 150 built the new image w/jenkins
* 150 pushed Dockerfile to repo
* 150 Pushed built image to dockerhub
* 150 deployed image to k8s cluster
* 150 screenshot showing their browser with the spinning flasks
* 150 script+output to show k8s cluster status, 400 points if output shows correct functioning(e.g. pods, nodes, deployments, etc... of app) output+script pushed to github
* 50 submitted pull request with all their changes


## How to Submit

#### Submitting assignment
* from the browser, navigate to the _forked_ project from **your** github account.
* click the `Pull Requests` tab.
* select `New Pull Request`
# Components
* Git CLI
* Used to commit and push code to remote code repository
* Docker
* Used to create image of the code build
* DockerHub
* Used to store docker image that is built
* minikube
* Used to spawn kubernetes nodes
* Python - Flask
* Used to run the web application
* Jenkins
* Used to create continuous integration and delivery build pipeline. This runs the docker commands to build the image and upload to DockerHub
* Terraform
* Used to deploy kubernetes cluster onto the cloud (ex. AWS)

# Monitoring
* Monitoring is done using the ELK stack and Metricbeat:
* Metricbeat - collects monitoring metrics such as CPU/Memory/Disk usage and feeds data to Logstash
* Elasticsearch - used to index log data and make it queryable
* Logstash - used for collect log data, enrich it, and send it to Elasticsearch. Sends email alerts if thresholds are breached for CPU usage
* Kibana - used to visualize log data and provide a front end graphical user interface for the user to search through logs
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask==0.12
2 changes: 2 additions & 0 deletions steps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t web .
docker run --name mycontainer -p 5000:5000 -d web
2 changes: 1 addition & 1 deletion web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def main():
return render_template('index.html')

if __name__ == "__main__":
app.run(host="localhost", port=8080, debug=True)
app.run(host='0.0.0.0')