Giter Site home page Giter Site logo

hamidgholami / flask-cd Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 363 KB

This is a web application project which is written by Flask. Also there are some practices regarding creating infrastructure as code (Terraform, Ansible, Vagrant) and installing kubernetes cluster (via ansible-playbook) and preparing CI/CD pipline for deploying the application on k8s cluster.

License: MIT License

Dockerfile 3.21% Python 9.48% HTML 10.51% HCL 56.04% Jinja 20.77%
kubernetes k3s k3s-cluster kustomize ansible ansible-playbook terraform python python3 flask flask-application practice-project practice-programming docker dockerfile cicd vagrant iac infrastructure-as-code

flask-cd's Introduction

Simple WEB APP by Flask and Deploy on Kubernetes

This is a web application project which is written by Flask. Also there are some practices regarding creating infrastructure as code (Terraform, Ansible, Vagrant) and installing kubernetes cluster (via ansible-playbook) and preparing CI/CD pipline for deploying the application on k8s cluster.

Docker Image

docker build -t flaskcd:latest .

Also prepared docker image is accessed.

docker pull hamidgholami/flaskcd:latest

Create a container from the image.

docker run --rm --name my-flask -d -p 8080:8080 flaskcd

Now visit http://localhost:8080

Verify the running container

Verify by checking the container IP and hostname (ID):

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-flask
docker inspect -f '{{ .Config.Hostname }}' my-flask

Terraform

terraform destroy -var-file=dev.tfvars
terraform plan -var-file=dev.tfvars -out devtfplan.out
#
terraform apply "devtfplan.out"

Ansible

First change the IPs in inventory file.

[machine]
master ansible_host=192.168.11.X
worker-1 ansible_host=192.168.11.X
worker-2 ansible_host=192.168.11.X
[kuberlab]
master
worker-1
worker-2

Afterwards run ansible-playbook

ansible-playbook -i provisioning/inventory site.yml

Deploy on Kubernetes

kubectl apply -k kubernetes/

Load Balancing

For aiming to this we can use 2 kinds of architecture.

  1. Scenario One We can use Kubernetes ingress and service for loadbalancing traffics on Pods.

  1. Scenario Two We can use an external loadbalancer such as: HAProxy, AWS ALB, NGINX or any other tools and loadbalancing traffics on Pods.


TO DO

Preview
  • Adding DB (MySQL) and connecting the application to it and adding some forms in application.
  • Creating a StatefulSet for MySQL for deploying it on Kubernetes.
    • Configure clustring for MySQL in Kubernetes.
  • Implementing ROOK or longhorn as a StorageClass in Kubernetes.
  • Configuring provision in Terraform for using ansible-playbook for installing Kubernetes.
  • Creating helm chart for DB and APP.
  • Adding Sign Up in WEB APP through either AWS Cognito or internally.

flask-cd's People

Contributors

hamidgholami 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.