This repository of a Flask application is part of project for the DevOps course of DEVOPS Experts developer.
Instructor: Nuni Doron
First part of the project is about building a docker of web application with flask.
This section shows how to build your image and run a container for that image.
Note: Windows and Linux commands of the docker are the same.
Building the image of the Flask application as follow:
$ docker build -t flask-app:1.1 .Flags:
- t : the tag name of the image
Building the container for the image to run as follow:
$ docker run -p 8080:8080 -d --name FlaskApp flask-app:1.1Flags:
-
p : port connecting, the 8080 port of host with the expose port of 8080 of the container
-
d : detaching the container from the current terminal hence running daemon. --name: the name of the container
Note: if change the name/version of the container image update the "flaskapp:1.0". Also you can give different name to container as you please instead of the "FlaskApp" but don't forget you changed it.
$ docker compose up -d Flags:
- d : detaching the container from the current terminal hence running daemon.
Second part of the project is about building flask package using kubernetes and helm.
The default build will create a Deployment with HPA of the application and database deployoment with hourly updates to the database.
Below you can see and learn how to edit and change the basic struction of the package system created.
This section shows how to build your yaml files and run the system.
Note: Windows and Linux commands of the helm are the same.
The values.yaml file contains all the dynamic values. Which can be change such that can be made for better setting of the system.
For example the number of replicaCount:
values.yaml
replicaCount = 3You can see the yaml files via template command as follow:
$ helm template .you can overwrite the values.yaml with another yaml as followed:
$ helm template . -f test-values.yamlFlags:
- f : overwrite the overlapping keys with the give yaml file
Install the package(recommand setting up your own user and password for the database):
$ helm install flask-package . --set secert.data.mongodb-username="admin" --set secert.data.mongodb-password="pss321"Flags:
--set : overwrite a value of key in the values.yaml file
$ helm test flask-package --logsFlags: --logs : outputs the test results
Uninstall the package:
$ helm uninstall flask-package└── Flask-App/ # project's root directory.
├─flask-docker/
│ ├── flaskApp/ # contains the flask application
│ │ ├── assets/ # contains images and files for the html
│ │ ├── templates/ # contains the html files
│ │ ├── app.py # main to run the flask app
│ │ └── requirements.txt # app requirements
│ ├── docker-compose.yml # docker compose file to combine the flask app with other functions
│ ├── README.md # description and instruions of flask-App
│ └── Dockerfile # builds app into a working docker
├── flask-package/ # helm package directory
│ ├── charts/ # helm charts
│ ├── crds/ # helm crds
│ ├── templates/ # contains the different kubernetes services
│ │ ├── configmap.yaml # kubernetes configmap
│ │ ├── cronjob.yaml # kubernetes cronjob
│ │ ├── dbservice.yaml # kubernetes service for database
│ │ ├── dbstatefulset.yaml # kubernetes statefulset hold database
│ │ ├── deployment.yaml # kubernetes deployment
│ │ ├── hpa.yaml # kubernetes horizontal pod autoscaling (hpa)
│ │ ├── NOTES.txt # text note on install of package
│ │ ├── persistentvolume.yaml # kubernetes persistent volume
│ │ ├── persistentvolumeclaim.yaml # kubernetes persistent volume claim
│ │ ├── secret.yaml # kubernetes secert
│ │ ├── service.yaml # kubernetes service for flask
│ │ └── serviceaccount.yaml # kubernetes service account
│ ├── Chart.yaml # helm Chart
│ ├── README.md # description and instruions of Flask-Orchestration
│ ├── values.schema.json # helm values schema
│ └── values.yaml # helm values
├── flask-jenkins/ # jenkins directory
│ ├── jenkins/ # contains the pipeline configuration files
│ │ ├── main.tf # TBA
│ │ └── pipeline.groovy # groovy pipeline script
│ └── README.md # description and instruions of flask jenkins
└── README.md # description and instruions of the project